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

Add reference target #10995

Open
wants to merge 26 commits into
base: main
Choose a base branch
from

Conversation

dandclark
Copy link
Contributor

@dandclark dandclark commented Feb 5, 2025

Reference Target allows authors to specify an element inside a shadow root to be the target of any ID references referring to the host element. This would enable IDREF attributes such as for and aria-labelledby to refer to elements inside a component's shadow DOM while maintaining encapsulation of the internal details of the shadow DOM.

See the reference target explainer.

At a high level, the spec change consists of these parts:

  • Define the concept of "resolving the reference target" on an element, following an IDREF from a host element to its target in the shadow, and potentially recursing.
  • Update the get-the-attr-associated-element algorithm (and its array-of-elements form) to follow reference target.
  • Centralize the definitions of ID reference attributes and list-of-ID-reference attributes as "element reference" and "set of element reference" attributes instead of repeating these definitions throughout the spec.
  • Update uses of ID throughout the spec, where applicable, to use the new reference-target-aware get-the-attr-associated-element.
  • Avoid exposing reference target elements in shadows from element-returning IDL properties by retargeting the result before returning.

See also the corresponding whatwg/dom#1353 which adds the definition of reference target used in this PR.
 

(See WHATWG Working Mode: Changes for more details.)


/common-dom-interfaces.html ( diff )
/common-microsyntaxes.html ( diff )
/dom.html ( diff )
/form-control-infrastructure.html ( diff )
/form-elements.html ( diff )
/forms.html ( diff )
/index.html ( diff )
/indices.html ( diff )
/infrastructure.html ( diff )
/input.html ( diff )
/microdata.html ( diff )
/parsing.html ( diff )
/popover.html ( diff )
/scripting.html ( diff )
/tables.html ( diff )

@dandclark dandclark changed the title Add shadowrootreferencetarget attribute to template Add reference target Feb 6, 2025
alice and others added 5 commits March 14, 2025 16:20
…d make some tweaks in the Reflection section
Collapse most of the 'reset the form owner' checks into one that just watches for changes to the form(attr)-associated-element.
@dandclark dandclark requested review from domenic and annevk March 18, 2025 00:17
@dandclark dandclark marked this pull request as ready for review March 18, 2025 00:30
@dandclark
Copy link
Contributor Author

@annevk, @domenic, this isn't quite ready to land yet as there are still a few open questions to sort out (at least WICG/webcomponents#1087 and WICG/webcomponents#1093), plus missing implementor positions. But I don't expect most of the mechanics in this PR to change, so I think it would be great to get feedback on whether the approach we've used here is agreeable.

See also whatwg/dom#1353

Thanks!

@alice
Copy link
Contributor

alice commented Mar 19, 2025

There's also a WIP PR against ARIA to account for these changes: w3c/aria#2474

There are some open questions being discussed there on exactly how to refer to the HTML concepts, since ARIA needs to be language-independent, but it will certainly refer to these spec concepts in some form.

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

Successfully merging this pull request may close these issues.

2 participants