Implement customElements.upgrade()
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Aug 2018 19:25:23 +0000 (19:25 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 2 Aug 2018 19:25:23 +0000 (19:25 +0000)
commite09054e68da8e2ca57bff7cbf3377138f9cfc97c
tree52fe8657713e33da014742e1b6be259739e0a7d5
parentdc075cb9b4a8a3c4f73f580d47a2e6dd941814a9
Implement customElements.upgrade()
https://bugs.webkit.org/show_bug.cgi?id=183397

Reviewed by Frédéric Wang.

LayoutTests/imported/w3c:

Rebaseline the test now that we're passing.

* web-platform-tests/custom-elements/custom-element-registry/upgrade-expected.txt:

Source/WebCore:

Added the support to upgrade custom elements directly. Ordinarily, custom elements get upgraded as they are
inserted / connected into a document but some script libraries and authors want to be able to upgrade them before that.
Also see https://github.com/w3c/webcomponents/issues/710

Implemented the method as specified at:
https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-upgrade

    When invoked, the upgrade(root) method must run these steps:
    1. Let candidates be a list of all of root's shadow-including inclusive descendant elements,
       in shadow-including tree order.
    2. For each candidate of candidates, try to upgrade candidate.

Tests: imported/w3c/web-platform-tests/custom-elements/custom-element-registry/upgrade.html

* dom/CustomElementReactionQueue.cpp:
(WebCore::CustomElementReactionQueue::enqueueElementUpgradeIfDefined): Removed the assertion that the upgraded element
is connected since the whole point of this API is to upgrade a disconnected element.
* dom/CustomElementRegistry.cpp:
(WebCore::upgradeElementsInShadowIncludingdescendants): Added.
(WebCore::CustomElementRegistry::upgrade): Added.
* dom/CustomElementRegistry.h: Forward declare DeferredPromise instead of unnecessarily including JSDOMPromiseDeferred.h.
* dom/CustomElementRegistry.idl:
* dom/Element.cpp:
(WebCore::Element::insertedIntoAncestor): Moved the assertion here.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@234507 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/custom-elements/custom-element-registry/upgrade-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/dom/CustomElementReactionQueue.cpp
Source/WebCore/dom/CustomElementRegistry.cpp
Source/WebCore/dom/CustomElementRegistry.h
Source/WebCore/dom/CustomElementRegistry.idl
Source/WebCore/dom/Element.cpp