Skip to content
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

ARIA reflection polyfill should treat setting undefined the same as null #3284

Open
nolanlawson opened this issue Jan 12, 2023 · 2 comments
Open
Labels

Comments

@nolanlawson
Copy link
Contributor

Description

We treat setting null on aria* properties as equivalent to removing the attribute.

if (isNull(newValue)) {
this.removeAttribute(attrName);

But Chrome/Safari treat undefined the same way (and we don't):

const div = document.createElement('div')
div.ariaLabel = undefined
div.getAttribute('aria-label') // should be null

In Firefox, using our polyfill, the above is "undefined" instead of null.

Steps to Reproduce

Repro

@git2gus
Copy link

git2gus bot commented Jan 12, 2023

This issue has been linked to a new work item: W-12370589

@nolanlawson
Copy link
Contributor Author

Interestingly, it turns out this is not actually how the spec is written. I've filed a spec issue: w3c/aria#1858

However, it is consistently how Chrome/Safari behave. They treat undefined the same as null, whereas any other falsy values (0, NaN, "", etc.) do not remove the attribute.

I would vote that we align the polyfill with the de-facto implementations from Chrome/Safari. It would be bizarre if Firefox behaved differently from Chrome/Safari, or if the non-standard props like ariaLabelledBy behaved differently from the standard ones like ariaLabel. (The latter would be an observable change in all browsers, though.)

We can also wait to see if the spec authors want to push back against the browser implementations. I have a patch ready to go if we want to align with the de-facto implementation: 2f04edd

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant