connectedCallback is invoked during the removal of the element inside another element...
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2018 03:58:41 +0000 (03:58 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 12 Dec 2018 03:58:41 +0000 (03:58 +0000)
commit9268f4f69f89f3d6a77ef7b5661729117ae7f4cf
treea72072d496cd8bf66fe3ac1498e23cedb4e49bef
parentd585b4bb7aadc47d6ba4ee16a9e0575d0c6790af
connectedCallback is invoked during the removal of the element inside another element's connectedCallback
https://bugs.webkit.org/show_bug.cgi?id=183586
<rdar://problem/38403504>

Reviewed by Frédéric Wang.

Source/WebCore:

Align WebKit's behavior with Chrome/Firefox with regards to https://github.com/w3c/webcomponents/issues/760

After much discussion, it's unclear that there is a clear path forward to fixing the oddness that
the presence of a custom element reaction changes the timing at which another reaction callback gets invoked.
So matching Chrome/Firefox behaviors in this case seems the path of the least resistance to interoperability.

Namely, this patch makes WebKit not insert a custom element to the appropriate element queue when the element
does not have a matching reaction callback. Put it another way, steps 3-5 in would be done before step 6 in:
https://html.spec.whatwg.org/multipage/custom-elements.html#enqueue-a-custom-element-callback-reaction
    1. Let definition be element's custom element definition.
    2. Let callback be the value of the entry in definition's lifecycle callbacks with key callbackName.
    3. If callback is null, then return
    4. If callbackName is "attributeChangedCallback", then:
        1. Let attributeName be the first element of args.
        2. If definition's observed attributes does not contain attributeName, then return.
    5. Add a new callback reaction to element's custom element reaction queue, with callback function callback
       and arguments args.
    6. Enqueue an element on the appropriate element queue given element.

Test: fast/custom-elements/enqueue-custom-element-callback-reactions-inside-another-callback.html

* dom/CustomElementReactionQueue.cpp:
(WebCore::CustomElementReactionQueue::enqueueElementUpgrade):
(WebCore::CustomElementReactionQueue::enqueueConnectedCallbackIfNeeded):
(WebCore::CustomElementReactionQueue::enqueueDisconnectedCallbackIfNeeded):
(WebCore::CustomElementReactionQueue::enqueueAdoptedCallbackIfNeeded):
(WebCore::CustomElementReactionQueue::enqueueAttributeChangedCallbackIfNeeded):
(WebCore::CustomElementReactionQueue::enqueuePostUpgradeReactions):
(WebCore::CustomElementReactionQueue::enqueueElementOnAppropriateElementQueue): Renamed from ensureCurrentQueue.
* dom/CustomElementReactionQueue.h:

LayoutTests:

Added a W3C style testharness test.

* fast/custom-elements/enqueue-custom-element-callback-reactions-inside-another-callback-expected.txt: Added.
* fast/custom-elements/enqueue-custom-element-callback-reactions-inside-another-callback.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239096 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/custom-elements/enqueue-custom-element-callback-reactions-inside-another-callback-expected.txt [new file with mode: 0644]
LayoutTests/fast/custom-elements/enqueue-custom-element-callback-reactions-inside-another-callback.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/CustomElementReactionQueue.cpp
Source/WebCore/dom/CustomElementReactionQueue.h