{"action":"created","issue":{"url":"https://api.github.com/repos/w3c/webcomponents/issues/551","repository_url":"https://api.github.com/repos/w3c/webcomponents","labels_url":"https://api.github.com/repos/w3c/webcomponents/issues/551/labels{/name}","comments_url":"https://api.github.com/repos/w3c/webcomponents/issues/551/comments","events_url":"https://api.github.com/repos/w3c/webcomponents/issues/551/events","html_url":"https://github.com/w3c/webcomponents/issues/551","id":172614053,"number":551,"title":"connectedCallback timing when the document parser creates custom elements","user":{"login":"kojiishi","id":1274377,"avatar_url":"https://avatars.githubusercontent.com/u/1274377?v=3","gravatar_id":"","url":"https://api.github.com/users/kojiishi","html_url":"https://github.com/kojiishi","followers_url":"https://api.github.com/users/kojiishi/followers","following_url":"https://api.github.com/users/kojiishi/following{/other_user}","gists_url":"https://api.github.com/users/kojiishi/gists{/gist_id}","starred_url":"https://api.github.com/users/kojiishi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kojiishi/subscriptions","organizations_url":"https://api.github.com/users/kojiishi/orgs","repos_url":"https://api.github.com/users/kojiishi/repos","events_url":"https://api.github.com/users/kojiishi/events{/privacy}","received_events_url":"https://api.github.com/users/kojiishi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":25,"created_at":"2016-08-23T05:16:51Z","updated_at":"2016-08-24T22:56:26Z","closed_at":"2016-08-24T06:32:24Z","body":"From [a blink bug](http://crbug.com/639847), an author reported that `connectedCallback` is called too early in Blink.\r\n\r\n```\r\n<script>customElements.define('x-x', ...);\r\n<script>customElements.define('y-y', ...);\r\n<x-x>\r\n  <div></div>\r\n  <y-y></y-y>\r\n</x-x>\r\n```\r\nor [a sample code in jsfiddle](https://jsfiddle.net/mcd7bd82/).\r\n\r\nWhen current Blink impl runs this code, `this.children.length` is 1 in `connectedCallback` for `x-x`. This looks like matching to the spec to me, but I appreciate discussion here to confirm if my understanding is correct, and also to confirm if this is what we should expect.\r\n\r\nMy reading goes this way:\r\n\r\n1. The parser is in [the \"in body\" insertion mode].\r\n2. It sees `x-x` as **Any other start tag**, it [insert an HTML element].\r\n3. [insert a foreign element] says to [create an element for a token], then insert.\r\nNote that this \"insert\" is not a link, but I assume this is [insert a node]?\r\n4. In [insert a node], step 5.2.1 enqueues `connectedCallback`.\r\n5. In [enqueue a custom element callback reaction], it adds to the backup element queue.\r\n6. The parser then reads `div`. In its [create an element for a token], _definition_ is null, so _will execute script_ is false. This `div` is then inserted.\r\n7. The parser then reads `y-y`. In its [create an element for a token], _definition_ is non-null, so _will execute script_ is true.\r\n8. Step 6.2 perform a microtask checkpoint if _will execute script_ is true, so the `connectedCallback` runs here.\r\n\r\nAm I reading the spec correctly? If so, is this what we should expect?\r\n\r\n@domenic @dominiccooney @rniwa \r\n\r\n[create an element for a token]: https://html.spec.whatwg.org/multipage/syntax.html#create-an-element-for-the-token\r\n[enqueue a custom element callback reaction]: https://html.spec.whatwg.org/multipage/scripting.html#enqueue-a-custom-element-callback-reaction\r\n[insert a node]: https://dom.spec.whatwg.org/#concept-node-insert\r\n[insert a foreign element]: https://html.spec.whatwg.org/multipage/syntax.html#insert-a-foreign-element\r\n[insert an HTML element]: https://html.spec.whatwg.org/multipage/syntax.html#insert-an-html-element\r\n[the \"in body\" insertion mode]: https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody\r\n"},"comment":{"url":"https://api.github.com/repos/w3c/webcomponents/issues/comments/242233986","html_url":"https://github.com/w3c/webcomponents/issues/551#issuecomment-242233986","issue_url":"https://api.github.com/repos/w3c/webcomponents/issues/551","id":242233986,"user":{"login":"domenic","id":617481,"avatar_url":"https://avatars.githubusercontent.com/u/617481?v=3","gravatar_id":"","url":"https://api.github.com/users/domenic","html_url":"https://github.com/domenic","followers_url":"https://api.github.com/users/domenic/followers","following_url":"https://api.github.com/users/domenic/following{/other_user}","gists_url":"https://api.github.com/users/domenic/gists{/gist_id}","starred_url":"https://api.github.com/users/domenic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domenic/subscriptions","organizations_url":"https://api.github.com/users/domenic/orgs","repos_url":"https://api.github.com/users/domenic/repos","events_url":"https://api.github.com/users/domenic/events{/privacy}","received_events_url":"https://api.github.com/users/domenic/received_events","type":"User","site_admin":false},"created_at":"2016-08-24T22:56:25Z","updated_at":"2016-08-24T22:56:25Z","body":"Yeah, this might be worth someone doing a blog post on or similar."}}
{"actor":{"display_login":"domenic"}}