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 23306 - [Custom]: Add an ownerDocumentChanged callback
Summary: [Custom]: Add an ownerDocumentChanged callback
Status: RESOLVED WONTFIX
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: 14968
  Show dependency treegraph
 
Reported: 2013-09-20 17:02 UTC by Dominic Cooney
Modified: 2013-09-21 00:10 UTC (History)
1 user (show)

See Also:


Attachments

Description Dominic Cooney 2013-09-20 17:02:21 UTC
Many elements depend on their browsing context. For example, if you were trying to implement a Custom Element that behaves like IMG, the HTML spec opines:

"In a browsing context where scripting is enabled, user agents must obtain images immediately."

That means it is necessary to observe ownerDocument changes, since the ownerDocument is an element's link to its browsing context, and moving one of these elements to a new browsing context necessitates some immediate processing step (in this hypothetical case, obtaining images.)

It should be called ownerDocumentChangedCallback since ownerDocument is the name of the DOM property of the element. This callback should take two parameters, documents, the old document and new document.

In the case of moving an element from in the document tree of one browsing context to being in the document tree of another browsing context, the ordering of this callback relative to the entered/left view callbacks should be:

leftViewCallback of the old document
ownerDocumentChangedCallback old document to new document
enteredViewCallback of the new document
Comment 1 Steve Orvell 2013-09-20 23:15:08 UTC
I think this callback is not necessary right now. I suggested it as an important platform signal, but upon further reflection, entered/leftView should be sufficient.

For example, when changing documents <img> actually doesn't obtain images until it enters the document tree (verified on Chrome and Firefox). A quick scan of the blink codebase indicates this concept is used but it's for pretty arcane reasons that probably won't come up often for custom elements.
Comment 2 Dominic Cooney 2013-09-21 00:10:04 UTC
Retracting.