In a web component, can this throw? class MyComponent extends HTMLElement { constructor() { super(); this.constructed = true; } connectedCallback() { if (!this.constructed) throw 'Lifecycle design is important' } }
-
Show this thread
-
@slightlylate is "yes" working as intended? Safari and Chrome seem to agree to sometimes call connectedCallback inside the super() call before running the constructor. Would be nice to spec running the callback in microtask after construction.1 reply 0 retweets 1 likeShow this thread -
-
Domenic is o podium at TC39 at this very moment, should I put this tweet on the queue? :P
1 reply 0 retweets 2 likes -
I mean...if you think it'll get
@cramforce an answer sooner -- I'm in a@w3ctag meeting discussing conflict resolution process across SDOs --
1 reply 0 retweets 0 likes -
Replying to @slightlylate @kosamari and
Spec says that `connectedCallback()` is called when a shadow-including root is part of the document. This can happen in several ways; either synchronous upgrade (thanks Apple! "Thapple". *sigh*) or addition to the document (think `appendChild(el)`): https://dom.spec.whatwg.org/#connected
1 reply 0 retweets 2 likes -
Replying to @slightlylate @kosamari and
Also, `upgrade()`: https://html.spec.whatwg.org/multipage/custom-elements.html#dom-customelementregistry-upgrade …
2 replies 0 retweets 0 likes -
Replying to @slightlylate @kosamari and
So to answer the original question, I think that if somewhere in the constructor, `upgrade()` is called, you might see a synchronous call to `connectedCallback`. Looking for other ways for this to happen.
1 reply 0 retweets 0 likes
This is the relevant section: https://html.spec.whatwg.org/multipage/custom-elements.html#custom-element-reactions …
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.
& Web Standards TL; Blink API OWNER
Named PWAs w/
DMs open. Tweets my own; press@google.com for official comms.