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

Here's the problem as simply explained as I can.

Suppose I wish to register two element classes, `SomeElement` and `OtherElement`. Then, suppose the pre-existing markup exists:

```html
<some-el>
  <other-el>
  </other-el>
</some-el>
```

Then, the following JS is executed:

```js
document.registerElement('some-el', SomeElement)
document.registerElement('other-el', OtherElement)
```
In an attempt to describe the problem I see from observing Chrome's v0 behavior, it seems that the first call to `document.registerElement('some-el', SomeElement)` causes `some-el` elements to be upgraded and their `attachedCallback` methods to be fired before the registration of `OtherElement`, so the children of the `some-el` will not be of the correct type when `attachedCallback` is called. By deferring logic with the `setTimeout` hack shown in #558, I can run logic *after* the children have also been upgraded to be of type `OtherElement` (*after* the execution of `document.registerElement('other-el', OtherElement)`).

-- 
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-243254299

Received on Monday, 29 August 2016 21:00:18 UTC