Re: [w3c/webcomponents] [IDEA] deferred upgrade for Custom Elements. (#559)

@domenic The same problem persists using v1 API in Chrome Canary (see console output): https://jsfiddle.net/wkwmzLwL.

This is problematic because a parent elements may need to have branching logic depending on which type of custom element children are attached. f.e.

```js
class ElementThree extends HTMLElement {
    connectedCallback() {
        for (let child of this.children)
            if (child instanceof SomeElement)
                // ...
            else if (child instanceof OtherElement)
                // ...
            else if (child instanceof AnotherElement)
                // ...
    }
}
```

This can be solved using a timeout hack, so the code would become

```js
class ElementThree extends HTMLElement {
    connectedCallback() {
        setTimeout(() => {
            for (let child of this.children)
                if (child instanceof SomeElement)
                    // ...
                else if (child instanceof OtherElement)
                    // ...
                else if (child instanceof AnotherElement)
                    // ...
        }, 0)
    }
}
```

jsfiddle that shows the hack works (see output): https://jsfiddle.net/aqp4uaja

-- 
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/559#issuecomment-243286630

Received on Monday, 29 August 2016 23:18:50 UTC