[w3c/webcomponents] [feature request] change when upgrade/connected happens during parsing, so that it is the first event in the following microtask (#787)

At the moment, it seems that during parsing, a custom elements code can not defer to a microtask in order to observe children (and expect the children to be upgraded).

I explained this in detail here: https://github.com/w3c/webcomponents/issues/550#issuecomment-457992936

The main issue, put shortly, is that using `Promise.resolve().then()` to defer to a microtask does not allow a custom element to observe their children after their children have already been upgrade. The only way is to defer to a macrotask with `setTimeout`, which has the unwanted side effect of causing custom element code to execute **_after_** the code of any `<script>` tags that are located below the custom elements in parsing order.

I'm not sure if this is the right place, but this is a feature request to change the behavior so that elements that are about to be upgraded will be upgraded in the _first_ microtask following the connectedCallback of the current element. This way at least, `Promise.resolve().then()` can be used by custom elements authors to work with already-upgraded children, without having to defer code beyond the execution of end-user code which may following the custom elements in parsing order.

-- 
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/787

Received on Tuesday, 29 January 2019 03:41:45 UTC