Bug 183931 - connectedCallback is invoked by the HTML parser after child nodes had been inserted
Summary: connectedCallback is invoked by the HTML parser after child nodes had been in...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords: InRadar
Depends on: 188336
Blocks: 154907
  Show dependency treegraph
 
Reported: 2018-03-23 04:05 PDT by Andrea Giammarchi
Modified: 2018-08-22 03:02 PDT (History)
10 users (show)

See Also:


Attachments
Fixes the bug (3.92 KB, patch)
2018-08-14 21:42 PDT, Ryosuke Niwa
achristensen: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrea Giammarchi 2018-03-23 04:05:08 PDT
Accordingly with this Chromium bug:
https://bugs.chromium.org/p/chromium/issues/detail?id=821831

It looks like Webkit/Safari have a bug related to Custom Elements and their connectedCallback invoke,
always triggered *after* DOMContentLoaded, even if the definition of the element is known,
and the page is also already served.

Accordingly, using this test page as reference:
https://webreflection.github.io/eyeo/tests/ce.html

The correct result should most likely the following one:
```
constructor: 0
attributeChangedCallback: 0
a
b
c
connectedCallback: 3
ready: 3
```

In Webkit/Safari the result is instead this one:
```
constructor: 0
a
b
c
ready: 3
attributeChangedCallback: 3
connectedCallback: 3
```
Comment 1 Radar WebKit Bug Importer 2018-03-25 10:51:20 PDT
<rdar://problem/38843548>
Comment 2 Kent Tamura 2018-04-02 01:55:24 PDT
We're adding test cases for this issue to WPT.
https://github.com/w3c/web-platform-tests/pull/10251
Comment 3 Ryosuke Niwa 2018-08-14 16:33:19 PDT
We pass almost all test cases once the patch for the bug 188189 is landed but there's one test case in custom-elements/parser/parser-sets-attributes-and-children.html we fail:
HTML parser should call connectedCallback before appending child nodes
Comment 4 Ryosuke Niwa 2018-08-14 21:42:55 PDT
Created attachment 347149 [details]
Fixes the bug
Comment 5 Alex Christensen 2018-08-15 09:01:13 PDT
Comment on attachment 347149 [details]
Fixes the bug

View in context: https://bugs.webkit.org/attachment.cgi?id=347149&action=review

> Source/WebCore/ChangeLog:19
> +        (WebCore::HTMLConstructionSite::insertCustomElement): Fixed the bug by manually executign the scheduled tasks.

executing
Comment 6 Ryosuke Niwa 2018-08-15 11:59:21 PDT
Committed r234893: <https://trac.webkit.org/changeset/234893>
Comment 7 Frédéric Wang (:fredw) 2018-08-22 03:02:58 PDT
Comment on attachment 347149 [details]
Fixes the bug

View in context: https://bugs.webkit.org/attachment.cgi?id=347149&action=review

> Source/WebCore/ChangeLog:9
> +        Invoke the custom element reactions after constructing and inserting a custom element as specifed in step 3.3 of:

nit: specified