Skip to content

"look up a custom element registry" can be called with a DocumentFragment node #11227

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

Closed
AtkinsSJ opened this issue Apr 16, 2025 · 5 comments · Fixed by #11228
Closed

"look up a custom element registry" can be called with a DocumentFragment node #11227

AtkinsSJ opened this issue Apr 16, 2025 · 5 comments · Fixed by #11228
Labels
topic: custom elements Relates to custom elements (as defined in DOM and HTML) topic: parser

Comments

@AtkinsSJ
Copy link
Contributor

What is the issue with the HTML Standard?

"Look up a custom element registry" handles Elements, ShadowRoots, and Documents. But it can be called with a DocumentFragment. Specifically I'm seeing "create an element for the token" doing so, at step 6:

Let registry be the result of looking up a custom element registry given intended parent.

"Intended parent" here is a DocumentFragment, at least in some cases. (I haven't done an exhaustive search, I'm just getting crashes because of it. 😅) This doesn't have a custom element registry.

@annevk

@AtkinsSJ
Copy link
Contributor Author

It seems like the fix is as simple as:

  1. If node is a Document object, then return node's custom element registry.
  2. Return null.

@annevk
Copy link
Member

annevk commented Apr 16, 2025

Thanks! The signature also has to change.

@annevk
Copy link
Member

annevk commented Apr 16, 2025

Actually, when would this be a DocumentFragment? I thought the HTML parser always operated on a Document.

@annevk annevk added topic: parser topic: custom elements Relates to custom elements (as defined in DOM and HTML) labels Apr 16, 2025
@AtkinsSJ
Copy link
Contributor Author

IIRC, when parsing it uses a DocumentFragment as the parent, and then moves all its children into their actual location in the document.

@annevk
Copy link
Member

annevk commented Apr 16, 2025

Ah, I guess this can happen with a template element. And in that case we indeed want to use null so that seems correct.

annevk added a commit that referenced this issue Apr 16, 2025
Slightly modernize "create an element for the token" while here (#1706 remains).

Fixes #11227.
@annevk annevk closed this as completed in a83846a Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: custom elements Relates to custom elements (as defined in DOM and HTML) topic: parser
Development

Successfully merging a pull request may close this issue.

2 participants