-
Notifications
You must be signed in to change notification settings - Fork 825
chore: refactor away from looking at role attribute #4756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -2,6 +2,7 @@ import { sanitize } from '../commons/text'; | |||
import standards from '../standards'; | ||||
import { isVisibleToScreenReaders, isVisibleOnScreen } from '../commons/dom'; | ||||
import { parseTabindex } from '../core/utils'; | ||||
import { getExplicitRole } from '../commons/aria'; | ||||
|
||||
function autocompleteMatches(node, virtualNode) { | ||||
const autocomplete = virtualNode.attr('autocomplete'); | ||||
|
@@ -43,9 +44,10 @@ function autocompleteMatches(node, virtualNode) { | |||
|
||||
// The element has `tabindex="-1"` and has a [[semantic role]] that is | ||||
// not a [widget](https://www.w3.org/TR/wai-aria-1.1/#widget_roles) | ||||
const role = virtualNode.attr('role'); | ||||
const role = getExplicitRole(virtualNode); | ||||
console.log({ role }); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
const tabIndex = parseTabindex(virtualNode.attr('tabindex')); | ||||
if (tabIndex < 0 && role) { | ||||
if (tabIndex < 0 && virtualNode.hasAttr('role')) { | ||||
const roleDef = standards.ariaRoles[role]; | ||||
if (roleDef === undefined || roleDef.type !== 'widget') { | ||||
Comment on lines
49
to
52
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this use getRoleType? |
||||
return false; | ||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import { sanitize } from '../commons/text'; | ||
import { isVisibleOnScreen, isInTextBlock } from '../commons/dom'; | ||
import { getExplicitRole } from '../commons/aria'; | ||
|
||
function linkInTextBlockMatches(node) { | ||
const text = sanitize(node.innerText); | ||
const role = node.getAttribute('role'); | ||
const role = getExplicitRole(node); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You may want to update the selector to |
||
|
||
if (role && role !== 'link') { | ||
return false; | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getExplicitRole
already validates the role if it returns, otherwise it returnsnull
for an invalid role. So we don't have to validate it again.