Skip to content

Conversation

captainbrosset
Copy link
Contributor

Fixes #2309.

This is a pretty pivotal feature for web components, as it allows to correctly map IDREF attributes to things inside the shadow DOM, without breaking encapsulation.

It's apparently been through an origin trial in Chromium, but I'm not sure what the plans are when it comes to shipping.
@dandclark can you share any plans on the above?

It's been proposed for Interop 26: web-platform-tests/interop#1011

@github-actions github-actions bot added feature definition Creating or defining new features or groups of features. tools and infrastructure Project internal tooling, such as linters, GitHub Actions, or repo settings labels Sep 24, 2025
@captainbrosset captainbrosset changed the title Add the referencetarget early feature Add the referencetarget feature Sep 24, 2025
@dandclark
Copy link

There are a few open issues that still need to be worked through, tracked from WICG/webcomponents#1086.

@@ -0,0 +1,8 @@
name: Reference target
description: The `referenceTarget` property of a `ShadowRoot` object forwards attributes such as `for` and `aria-labelledby` to elements inside a shadow DOM. This allows, for example, to link a `<label>` to its `<input>` even if the `<input>` is in the shadow DOM of a web component.
spec: https://github.com/WICG/webcomponents/blob/gh-pages/proposals/reference-target-explainer.md

Choose a reason for hiding this comment

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

Not sure if it's customary to link in-progress spec PRs for features in development, but if those are allowed here then these are the best spec links for the feature for now:
whatwg/html#10995
whatwg/dom#1353

@@ -0,0 +1,8 @@
name: Reference target
description: The `referenceTarget` property of a `ShadowRoot` object forwards attributes such as `for` and `aria-labelledby` to elements inside a shadow DOM. This allows, for example, to link a `<label>` to its `<input>` even if the `<input>` is in the shadow DOM of a web component.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
description: The `referenceTarget` property of a `ShadowRoot` object forwards attributes such as `for` and `aria-labelledby` to elements inside a shadow DOM. This allows, for example, to link a `<label>` to its `<input>` even if the `<input>` is in the shadow DOM of a web component.
description: The `referenceTarget` property of a `ShadowRoot` object forwards attributes such as `for` and `aria-labelledby` to elements inside a shadow DOM. You can use this to, for example, link a `<label>` to its `<input>` even if the `<input>` is in the shadow DOM of a web component.

Comment on lines +6 to +8
# No BCD keys yet as the feature hasn't shipped anywhere.
# It's being implemented in Chromium, and has gone through an origin trial in 133-135:
# https://chromestatus.com/feature/5188237101891584
Copy link
Collaborator

Choose a reason for hiding this comment

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

In lieu of "no BCD" comments, I think it would be nice if we started listing predicted BCD keys. So in this case, something like:

Suggested change
# No BCD keys yet as the feature hasn't shipped anywhere.
# It's being implemented in Chromium, and has gone through an origin trial in 133-135:
# https://chromestatus.com/feature/5188237101891584
# Expected keys via Chrome origin trial in 133-135 https://chromestatus.com/feature/5188237101891584
# api.Element.attachShadow.options_referenceTarget_parameter

and so on

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

Labels

feature definition Creating or defining new features or groups of features. tools and infrastructure Project internal tooling, such as linters, GitHub Actions, or repo settings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reference Target

3 participants