[Webkit-unassigned] [Bug 188284] New: Custom elements created by the parser in a connected position have their constructors and connectedCallbacks called out of order

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Thu Aug 2 16:32:38 PDT 2018


https://bugs.webkit.org/show_bug.cgi?id=188284

            Bug ID: 188284
           Summary: Custom elements created by the parser in a connected
                    position have their constructors and
                    connectedCallbacks called out of order
           Product: WebKit
           Version: Safari 11
          Hardware: Unspecified
                OS: Unspecified
            Status: NEW
          Severity: Normal
          Priority: P2
         Component: HTML DOM
          Assignee: webkit-unassigned at lists.webkit.org
          Reporter: bicknellr at google.com
                CC: cdumez at apple.com

Created attachment 346427

  --> https://bugs.webkit.org/attachment.cgi?id=346427&action=review

A page with custom elements that log when their constructor and connectedCallback are called.

When a group of custom elements are created through the parser (either because they are in the main document's HTML or are in a string being set to a connected element's `innerHTML` property), they are all constructed before any have their `connectedCallback` called.

For example, for this tree:

<c-e id="A">
  <c-e id="B"></c-e>
</c-e>
<c-e id="C"></c-e>

Safari calls the constructor and connectedCallback of each in this order:

- constructor A
- constructor B
- constructor C
- connectedCallback A
- connectedCallback B
- connectedCallback C

However, the order should be this:

- constructor A
- connectedCallback A
- constructor B
- connectedCallback B
- constructor C
- connectedCallback C


Relevant spec text:
https://html.spec.whatwg.org/multipage/parsing.html#create-an-element-for-the-token

The 'in-document HTML' case would have 'will execute script' set to true, meaning that the interleaved order above is the expected order, AFAICT.

I think Safari's `innerHTML` is correct here though: it would have 'will execute script' set to false, so the connectedCallback reactions would all be delayed until they're popped at the end.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20180802/69584916/attachment.html>


More information about the webkit-unassigned mailing list