Skip to content

Fix type mismatch for reflected FrozenArray<T>?#12148

Open
gmvrpw wants to merge 1 commit intowhatwg:mainfrom
gmvrpw:main
Open

Fix type mismatch for reflected FrozenArray<T>?#12148
gmvrpw wants to merge 1 commit intowhatwg:mainfrom
gmvrpw:main

Conversation

@gmvrpw
Copy link

@gmvrpw gmvrpw commented Feb 10, 2026

Currently, the "cached attr-associated elements" variable has a list of elements type but a null value can be assigned.

Browsers work logically as possible and ignore this strange behavior, which can be easily verified:

myDiv = document.createElement('div')
// <div>​</div>​
// cached attr-associated elements = [] 
// cached attr-associated elements object = null
myDiv.setAttribute('aria-describedby', 'id')
myDiv.ariaDescribedByElements
// [], but elements (result of **get the attr-associated elements**) is [] (myDiv is not connected),
// so "contents of elements ([]) is equal to the contents of this's cached attr-associated elements ([])" is true,
// so cached attr-associated elements object (null) must be returned.
  • At least two implementers are interested (and none opposed):
  • [Tests] custom-elements/element-internals-aria-element-reflection.html (as stated below)
  • Implementation bugs are filed: Not needed
  • Corresponding HTML AAM & ARIA in HTML issues & PRs: Not needed
  • MDN issue is filed: Not needed
  • The top of this comment includes a clear commit message to use.

/acknowledgements.html ( diff )
/common-dom-interfaces.html ( diff )

Currently, the "cached attr-associated elements" variable has a list of
elements type but a null value can be assigned.

This commit:

  - Changes the type of "cached attr-associated elements" from a list of
    of elements to a list of elements or null

  - Adds an additional null check before using the cached
    attr-associated elements in the getter steps
@zcorpan
Copy link
Member

zcorpan commented Feb 12, 2026

Thanks for this PR!

It's not editorial because there is a change in what is required. As such, there should be tests. Please put back the PR template. If browsers already pass the tests the implementer interest checkbox can be checked.

@zcorpan zcorpan added the needs tests Moving the issue forward requires someone to write tests label Feb 12, 2026
@gmvrpw
Copy link
Author

gmvrpw commented Feb 12, 2026

Thanks for clarifying. I'll return with the tests.

@annevk
Copy link
Member

annevk commented Feb 13, 2026

This is tested by custom-elements/element-internals-aria-element-reflection.html though only a single test.

@annevk
Copy link
Member

annevk commented Feb 13, 2026

But yeah, please restore the PR template as well as we want to do our due diligence here. cc @twilco

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is correct. I think we could also have returned early for elements being null, but that would keep around a garbage cached value for longer, which isn't exactly clean.

@gmvrpw
Copy link
Author

gmvrpw commented Feb 13, 2026

Description has been restored 🤖
It's a shame I saw these messages too late, so here's my implementation of the tests. Let me know if it's useless.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs tests Moving the issue forward requires someone to write tests

Development

Successfully merging this pull request may close these issues.

3 participants