[w3c/webcomponents] A way to detect if a custom element was constructed during customElements.define call? (#790)

F.e.,

```js
class MyEl extends HTMLElement {
 constructor() {
  if (/* constructedDuringCustomElementsDotDefineCall? */) {
    console.log('created during parsing')
  }
 }
 connectedCallback() {
  if (/* runningInTheCustomElementsDotDefineCall? */) {
    console.log('connected during parsing')
  }
 }
}
```

I think one way I can do this is to monkey patch `customElements.define` and set a var.

The reason is, because I'm finding that if I define elements **_after_** they have already been parsed, then creating a `MutationObserver` in the constructor _does not_ observe `childList` because the nodes that are being upgraded already have the children (no DOM mutation happened).

I'd still like to fire `childConnectedCallback` in this case, but the idea from https://github.com/w3c/webcomponents/issues/789 only works _during parsing_.

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

Received on Wednesday, 6 February 2019 07:02:55 UTC