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

DOM: createElement and createElementNS with scoped registries #50925

Merged
merged 2 commits into from
Feb 25, 2025

Conversation

annevk
Copy link
Member

@annevk annevk commented Feb 25, 2025

annevk added a commit to annevk/WebKit that referenced this pull request Feb 25, 2025
https://bugs.webkit.org/show_bug.cgi?id=288473
rdar://145557562

Reviewed by NOBODY (OOPS!).

This makes a variety of changes to align ourselves with the latest
Scoped Custom Element Registries proposal:

1. Accept DOMString in addition to ElementCreationOptions. This was
   already part of the DOM standard and is needed for compatibility.
   (Although to be fair the need has not been proven recently, but now
   does not seem like the time to find out.)
2. Have createElementNS take the same argument as
   createElementForBindings.
3. createHTMLElementWithNameValidation no longer needs both TreeScope
   and Document as they are once again the same.
4. Given that createHTMLElementWithNameValidation defaults registry to
   document.customElementRegistry it does not seem unlikely that
   registry is non-null so remove UNLIKELY there.
5. addToScopedCustomElementRegistryMap needs to be called by
   createElementForBindings and createElementNS as it's relevant for
   all elements. Since we only need to call it for scoped registries,
   we don't have to move the registry defaulting to
   document.customElementRegistry logic to these methods.

Tests are upstreamed here:
web-platform-tests/wpt#50925

* LayoutTests/imported/w3c/web-platform-tests/custom-elements/revamped-scoped-registry/Document-createElement.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/revamped-scoped-registry/Document-createElement.tentative.html:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/revamped-scoped-registry/Document-createElementNS.tentative-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/revamped-scoped-registry/Document-createElementNS.tentative.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/revamped-scoped-registry/w3c-import.log:
* Source/WebCore/dom/Document.cpp:
(WebCore::createHTMLElementWithNameValidation):
(WebCore::Document::createElementForBindings):
(WebCore::Document::createElementNS):
* Source/WebCore/dom/Document.h:
* Source/WebCore/dom/Document.idl:
@annevk annevk merged commit a52f979 into master Feb 25, 2025
17 checks passed
@annevk annevk deleted the annevk/createelement-scoped branch February 25, 2025 18:09
webkit-commit-queue pushed a commit to annevk/WebKit that referenced this pull request Feb 26, 2025
https://bugs.webkit.org/show_bug.cgi?id=288473
rdar://145557562

Reviewed by Ryosuke Niwa.

This makes a variety of changes to align ourselves with the latest
Scoped Custom Element Registries proposal:

1. Accept DOMString in addition to ElementCreationOptions. This was
   already part of the DOM standard and is needed for compatibility.
   (Although to be fair the need has not been proven recently, but now
   does not seem like the time to find out.)
2. Have createElementNS take the same argument as
   createElementForBindings.
3. createHTMLElementWithNameValidation no longer needs both TreeScope
   and Document as they are once again the same.
4. Given that createHTMLElementWithNameValidation defaults registry to
   document.customElementRegistry it does not seem unlikely that
   registry is non-null so remove UNLIKELY there.
5. addToScopedCustomElementRegistryMap needs to be called by
   createElementForBindings and createElementNS as it's relevant for
   all elements. Since we only need to call it for scoped registries,
   we don't have to move the registry defaulting to
   document.customElementRegistry logic to these methods.

Tests are upstreamed here:
web-platform-tests/wpt#50925

* LayoutTests/imported/w3c/web-platform-tests/custom-elements/revamped-scoped-registry/Document-createElement.tentative-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/revamped-scoped-registry/Document-createElement.tentative.html:
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/revamped-scoped-registry/Document-createElementNS.tentative-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/revamped-scoped-registry/Document-createElementNS.tentative.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/custom-elements/revamped-scoped-registry/w3c-import.log:
* Source/WebCore/dom/Document.cpp:
(WebCore::createHTMLElementWithNameValidation):
(WebCore::Document::createElementForBindings):
(WebCore::Document::createElementNS):
* Source/WebCore/dom/Document.h:
* Source/WebCore/dom/Document.idl:

Canonical link: https://commits.webkit.org/291093@main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants