Skip to content

Add referenceTarget to ShadowRootInit argument to attachShadow()#1062

Merged
Westbrook merged 2 commits intoWICG:gh-pagesfrom
behowell:reference-target/init-dict
Aug 12, 2024
Merged

Add referenceTarget to ShadowRootInit argument to attachShadow()#1062
Westbrook merged 2 commits intoWICG:gh-pagesfrom
behowell:reference-target/init-dict

Conversation

@behowell
Copy link
Copy Markdown
Contributor

From review feedback in the Chromium implementation CL, it may be good to add referenceTarget to the ShadowRootInit dictionary argument to attachShadow().
https://chromium-review.googlesource.com/c/chromium/src/+/5615615/comment/1a3651e1_4b117a02/

Copy link
Copy Markdown
Collaborator

@Westbrook Westbrook left a comment

Choose a reason for hiding this comment

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

LGTM, quick question, however:

What happens in the time between setting the referenceTarget, via either technique, and that element actual existing due to the innerHTML being set? Should we talk about that in any way?

@behowell
Copy link
Copy Markdown
Contributor Author

behowell commented Aug 8, 2024

@Westbrook

What happens in the time between setting the referenceTarget, via either technique, and that element actual existing due to the innerHTML being set? Should we talk about that in any way?

That's implicitly covered by the fact that reference target is a Live Reference. Basically, the reference target gets updated any time something changes in the DOM that affects it. For example adding elements to the shadow DOM tree by setting innerHTML will update the reference target. It's equivalent to the non-shadow-dom case: if you have <label for="foo">...</label> and then later add <input id="foo"> to the DOM, the label will be "updated" to be for the input.

That said, it might be worth expanding the Live References section to include mentions of the DOM changing, instead of only mentioning the referenceTarget changing. I can make that change in a separate PR.

@behowell
Copy link
Copy Markdown
Contributor Author

Added a follow-up PR to clarify the live references: #1067

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants