Re: [w3c/webcomponents] connectedCallback timing when the document parser creates custom elements (#551)

As Firefox seems to have implented a different behaviour (children being available in the `connectedCallback` outright), and as the polyfilled browsers (document-register-element) seem to also grant access to a custom element's children in the `connectedCallback`, would this be the way to implement it cross-browser with minimal performance impact?

```
class myElement extends HTMLElement {
    connectedCallback() {
        this.init();
    }

    init() {
        if (this.children.length) { 
            childrenAvailableCallback() 
        } else { 
            setTimeout(childrenAvailableCallback.bind(this), 0) 
        }
    }

    childrenAvailableCallback() {
        /* access to child elements available here */
    }
}
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/551#issuecomment-429242035

Received on Friday, 12 October 2018 08:08:49 UTC