On Feb 19, 2013 3:54 PM, "Dimitri Glazkov" <dglazkov@chromium.org> wrote:
> 2) Custom element constructor runs at the time of parsing HTML, as the
> tree is constructed.
>
> PROBLEM: Several implementers let me know that allowing to run JS
> while parsing HTML is not something they can accommodate in a
> reasonable timeframe.
>
> COMPROMISE: Turn constructor into a callback, which runs in a
> microtask at some later time (like upon encountering </script>).
>
> COST: Constructing an element when building a tree != createElement.
> Also, there's an observable difference between the callback and the
> constructor. Since the constructor runs before element is inserted
> into a tree, it will not have any children or the parent. At the time
> the callback is invoked, the element will already be in the tree--and
> thus have children and the parent.
Another cost is that when these elements will exist and be reachable from
script before their constructor runs.
In particular they wont always have had their constructor callback run when
the constructor callback of other elements in the same subtree runs.
/ Jonas