Skip to content

feat: support for referenceTarget shadow DOM feature #6626

Description

@Noleli

Prerequisites

Describe the Feature Request

When working with shadow DOM, it has historically not been possible to use IDREFs across shadow boundaries. This make it impossible to apply external labels or any relevant ARIA properties to an element (such as a form control) inside a component’s shadow root.

A recent web standard proposal, referenceTarget, addresses many of these challenges, and is now supported behind a flag in all major browsers.

This feature request is to add support for this web platform feature to Stencil.

Describe the Use Case

Support for referenceTarget would allow authors who use Stencil-created custom elements that embed reference targets in their shadow roots to use ID references to apply labels, ARIA attributes, and other IDREF-based features to those elements.

For example, say you have a Stencil component with the following rendered DOM structure:

<my-input>
  #shadow-root
    <div class="some-other-element"></div>
    <input id="internal-input">
</my-input>

If attachShadow() were called with attachShadow({ referenceTarget: "internal-input" }), an author would be able to apply a label as they would to any native form control:

<label for="name-input">Name</label>
<my-input id="name-input"></my-input>

Describe Preferred Solution

I would expect this to be an option on the shadow component option.

boolean | { delegatesFocus?: boolean, slotAssignment?: 'manual' | 'named', referenceTarget?: string }

Using it to create the custom element from the example above:

@Component({
  tag: "my-input",
  shadow: {
    referenceTarget: "internal-input",
    delegatesFocus: true
  },
  formAssociated: true
})

Describe Alternatives

No response

Related Code

No response

Additional Information

No response

Activity

  1. added
    Feature: Want this? Upvote it!
    on Mar 3, 2026
  2. added
    Stencil v5
    and removed
    Feature: Want this? Upvote it!
    on Mar 9, 2026
  3. added
    Feature: Want this? Upvote it!
    on Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Feature: Want this? Upvote it!Stencil v5

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions