Repository navigation
Conversation
The role attribute is a space-separated token list per WAI-ARIA; the
first token is the element's effective role. Exact attribute selectors
([role="table"]) and exact string comparisons (getAttribute("role"))
miss multi-token values like role="table grid", so such containers
were rejected as non-tables and their rows/cells were not found.
- Switch every [role="X"] selector to [role~="X"] for whitespace-token
matching (table, grid, treegrid, list, row, cell, gridcell,
columnheader, rowheader, rowgroup, listitem).
- Add ariaRole() returning the first role token, mirroring the existing
ariaSpan/ariaIndex/ariaCount helpers, and use it at the two
presentation/none guards and two columnheader/rowheader classification
sites so first-token semantics hold where ~= cannot express them.
Closes Tencent#595
Issue Tencent#595 notes that role is a space-separated token list whose first token is the effective role, and explicitly warns against simply switching [role="x"] to [role~="x"]: ~= matches any token, so role="heading table" would be misclassified as a table. Resolve the effective role (first token) via ariaRole() and predicate-based helpers instead of CSS role selectors. - Add isTableElement/isListElement/isRowElement/isRowgroupElement predicates and closestBy/selectByRole helpers, all using ariaRole() so only the first token decides, matching how Chromium resolves ARIA roles. - Replace every [role~="x"] selector and the matches()/closest()/ querySelector() call sites that used them with the matching predicate (table, grid, treegrid, list, row, rowgroup, cell, gridcell, columnheader, rowheader, listitem). - Add regression test: role="heading table" is rejected as a non-table (first token "heading"), while role="table grid" is still extracted. Closes Tencent#595
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(extract): match ARIA role attribute as a token list
The role attribute is a space-separated token list per WAI-ARIA; the
first token is the element's effective role. Exact attribute selectors
([role="table"]) and exact string comparisons (getAttribute("role"))
miss multi-token values like role="table grid", so such containers
were rejected as non-tables and their rows/cells were not found.
matching (table, grid, treegrid, list, row, cell, gridcell,
columnheader, rowheader, rowgroup, listitem).
ariaSpan/ariaIndex/ariaCount helpers, and use it at the two
presentation/none guards and two columnheader/rowheader classification
sites so first-token semantics hold where ~= cannot express them.
Closes #595