This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 21641 - [Custom]: Consider firing insertedCallback when Custom Element is upgraded when already inserted in dom.
Summary: [Custom]: Consider firing insertedCallback when Custom Element is upgraded wh...
Status: RESOLVED FIXED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Dimitri Glazkov
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 18720
  Show dependency treegraph
 
Reported: 2013-04-09 18:58 UTC by Steve Orvell
Modified: 2013-04-30 21:34 UTC (History)
3 users (show)

See Also:


Attachments

Description Steve Orvell 2013-04-09 18:58:43 UTC
I believe there is now agreement that the spec should include inserted/removedCallbacks that are fired when a custom element is inserted/removed from dom.

We may want to fire the insertedCallback when a custom element is upgraded when already in dom.

Assume, for example, a developer wants to add event listeners when a custom element is inserted. If we do not call inserted on upgrade, the developer is forced to write boilerplate code in readyCallback that checks if the element is already in dom and calls the same code as the insertedCallback would.
Comment 1 Scott Miles 2013-04-09 19:08:32 UTC
I agree we need this for the reasons given.
Comment 2 Olli Pettay 2013-04-09 19:19:09 UTC
Why do we need a special notification when element is inserted/removed from DOM?
We have MutationObserver for that.
Comment 3 Dominic Cooney 2013-04-10 06:20:41 UTC
I support this change. This simplifies the state machine which controls whether I should start doing actions (animation, retrieving stuff, event listening, etc.) and stop doing actions.

Olli: It seems unfortunate to for custom element authors to use MutationObservers for this. All created custom elements will need to register mutation observers over the entire document to see whether one of their elements is inserted anywhere.

It seems much more efficient for implementations and simpler for authors if the UA provides these callbacks. I *think* it is fine for the callbacks to be timed to the microtask like a MutationObserver to avoid the pathologies of MutationEvents.
Comment 4 Olli Pettay 2013-04-10 10:43:01 UTC
Ok, I guess I need to see actual proposal how this would work before commenting more.
Comment 5 Dimitri Glazkov 2013-04-30 21:34:36 UTC
https://dvcs.w3.org/hg/webcomponents/rev/cd964833d307