-
Notifications
You must be signed in to change notification settings - Fork 466
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
feat(ByRole): Allow filter by disabled state #1221
base: main
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 |
---|---|---|
|
@@ -290,6 +290,29 @@ function computeAriaCurrent(element) { | |
) | ||
} | ||
|
||
const elementsSupportingDisabledAttribute = new Set([ | ||
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. I might be missing something, but this seems to me like something that should be defined in 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. Also, I see we have something like this in 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. I don't want to put more stuff into 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. Done: eps1lon/dom-accessibility-api#919 |
||
'button', | ||
'fieldset', | ||
'input', | ||
'optgroup', | ||
'option', | ||
'select', | ||
'textarea', | ||
]) | ||
|
||
/** | ||
* @param {Element} element - | ||
* @returns {boolean} - | ||
*/ | ||
function computeAriaDisabled(element) { | ||
return elementsSupportingDisabledAttribute.has(element.localName) && | ||
element.hasAttribute('disabled') | ||
? // https://www.w3.org/TR/html-aam-1.0/#html-attribute-state-and-property-mappings | ||
true | ||
: // https://www.w3.org/TR/wai-aria-1.1/#aria-disabled | ||
element.getAttribute('aria-disabled') === 'true' | ||
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. I think it's worth adding this to 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. Querying should not be used for assertions. For jest-dom i.e. there was a clear case why this wasn't as straight forward because it might contain footguns. /dom: queries based on a11y tree 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. I agree with that querying and asserting are two different operations. |
||
} | ||
|
||
/** | ||
* @param {Element} element - | ||
* @returns {boolean | undefined} - false/true if (not)expanded, undefined if not expand-able | ||
|
@@ -382,6 +405,7 @@ export { | |
computeAriaChecked, | ||
computeAriaPressed, | ||
computeAriaCurrent, | ||
computeAriaDisabled, | ||
computeAriaExpanded, | ||
computeAriaValueNow, | ||
computeAriaValueMax, | ||
|
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.
Just an idea, maybe for the completeness of this test, we should also add: