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

> You just need to iterate over child nodes inside the constructor ... Simple as that

Simple, right? That assumes your know inside the constructor if the Custom Elements would expect nodes to setup itself, or not.

An empty custom element is a perfectly valid use case that fails your simple approach.

A Custom Element that might be forever empty or optionally have nodes to dictate its status is another perfect common use case, i.e. `my-select` that would see its shape only after known its content has one opt more `my-option` or not, before setting up its ShadowDOM or its final shape.

How do you know when it's the time for that component to initialize itself **once** if not by trusting some parent has a MutationObserver to take indirectly care of that?

This is impractical, and what is missing is a way to know, from the component, the component body has been fully parsed, which should happen **once** for a component lifecycle, and never more than once.

Just like a constructor, with all possible setup available, including a dirty `innerHTML`, which instead throws arbitrary errors if the custom element is being upgraded but not fully known (`childNodes.length = 0`).

As simple as that.

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

Received on Sunday, 14 October 2018 10:31:01 UTC