Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 30db0392404836cdf3341bbe233d3e55e5886017
      
https://github.com/WebKit/WebKit/commit/30db0392404836cdf3341bbe233d3e55e5886017
  Author: Ryosuke Niwa <[email protected]>
  Date:   2025-11-19 (Wed, 19 Nov 2025)

  Changed paths:
    M 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/Element-customElementRegistry-exceptions.html
    M 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/Element-customElementRegistry.html
    M 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/ShadowRoot-init-customElementRegistry-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/ShadowRoot-init-customElementRegistry.html
    A 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-custom-element-registry-customelementregistry-attribute-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-custom-element-registry-customelementregistry-attribute-in-xhtml-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-custom-element-registry-customelementregistry-attribute-in-xhtml.xhtml
    A 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-custom-element-registry-customelementregistry-attribute.html
    A 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-registry-append-does-not-upgrade-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-registry-append-does-not-upgrade.html
    M 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-registry-define-upgrade-criteria-expected.txt
    M 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-registry-define-upgrade-criteria.html
    M Source/WebCore/bindings/js/JSCustomElementInterface.cpp
    M Source/WebCore/dom/CustomElementRegistry.cpp
    M Source/WebCore/dom/Document.cpp
    M Source/WebCore/dom/Element.cpp
    M Source/WebCore/dom/ElementCreationOptions.h
    M Source/WebCore/dom/ElementCreationOptions.idl
    M Source/WebCore/dom/Node.cpp
    M Source/WebCore/dom/ShadowRootInit.h
    M Source/WebCore/dom/ShadowRootInit.idl
    M Source/WebCore/html/HTMLAttributeNames.in
    M Source/WebCore/html/parser/HTMLConstructionSite.cpp
    M Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp

  Log Message:
  -----------
  Introduce customelementregistry content attribute and avoid changing null 
registry when inserting a node
https://bugs.webkit.org/show_bug.cgi?id=302583

Reviewed by Chris Dumez.

This PR introduces customelementregistry content attribute on element which 
sets the custom element registry of an element to null,
It also adds the support for specifying `null` in `customElementRegistry` to 
use null custom element registry in `document.createElement`,
`document.createElementNS`, and `element.attachShadow`.

In addition, this PR changes the semantics of inserting a node so that 
inserting an element with null custom element registry will not
update its custom element registry to that of the new parent.

These behavior changes were discussed during TPAC as explained in: 
https://github.com/whatwg/dom/issues/1413#issuecomment-3530198733

Test: 
imported/w3c/web-platform-tests/custom-elements/registries/scoped-custom-element-registry-customelementregistry-attribute.html
      
imported/w3c/web-platform-tests/custom-elements/registries/scoped-custom-element-registry-customelementregistry-attribute-in-xhtml.xhtml
      
imported/w3c/web-platform-tests/custom-elements/registries/scoped-registry-append-does-not-upgrade.html

* 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/Element-customElementRegistry-exceptions.html:
* 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/Element-customElementRegistry.html:
* 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/ShadowRoot-init-customElementRegistry-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/ShadowRoot-init-customElementRegistry.html:
* 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-custom-element-registry-customelementregistry-attribute-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-custom-element-registry-customelementregistry-attribute-in-xhtml-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-custom-element-registry-customelementregistry-attribute-in-xhtml.xhtml:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-custom-element-registry-customelementregistry-attribute.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-registry-append-does-not-upgrade-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-registry-append-does-not-upgrade.html:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-registry-define-upgrade-criteria-expected.txt:
* 
LayoutTests/imported/w3c/web-platform-tests/custom-elements/registries/scoped-registry-define-upgrade-criteria.html:
* Source/WebCore/bindings/js/JSCustomElementInterface.cpp:
(WebCore::JSCustomElementInterface::constructElementWithFallback): Add the 
element to scoped custom element registry map if needed.
* Source/WebCore/dom/CustomElementRegistry.cpp:
(WebCore::enqueueUpgradeInShadowIncludingTreeOrder): Fixed the bug that this 
code wasn't accounting for null custom element registry.
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::createElementForBindings): Respect `null` being specified 
in Init dictionary.
(WebCore::Document::createElementNS): Ditto.
* Source/WebCore/dom/Element.cpp:
(WebCore::Element::attributeChanged): Mark the element as it uses null custom 
element registry if parser sets customelementregistry content attribute.
(WebCore::Element::insertedIntoAncestor): Rewrote the logic to update the 
custom element registry map.
* Source/WebCore/dom/ElementCreationOptions.h:
* Source/WebCore/dom/ElementCreationOptions.idl:
* Source/WebCore/dom/Node.cpp:
(WebCore::adoptCustomElementRegistryIfNotExplicitlySet): Added.
(WebCore::Node::moveShadowTreeToNewDocumentFastCase): Set the custom element 
registry if a given adopted node uses null registry.
(WebCore::Node::moveShadowTreeToNewDocumentSlowCase): Ditto.
(WebCore::Node::moveNodeToNewDocumentFastCase): Ditto.
(WebCore::Node::moveNodeToNewDocumentSlowCase): Ditto.
* Source/WebCore/dom/ShadowRootInit.h:
* Source/WebCore/dom/ShadowRootInit.idl:
* Source/WebCore/html/HTMLAttributeNames.in:
* Source/WebCore/html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::createHTMLElementOrFindCustomElementInterface): 
Handle customelementregistry content attribute.
* Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::handleNamespaceAttributes):
(WebCore::handleElementAttributes):
(WebCore::XMLDocumentParser::startElementNs): Handle customelementregistry 
content attribute.

Canonical link: https://commits.webkit.org/303300@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to