- From: Boris Zbarsky <bzbarsky@MIT.EDU>
- Date: Fri, 29 Oct 2004 12:31:57 -0500
- To: www-svg@w3.org
I am proposing that we add an event that fires when the bound element is inserted into the document to sXBL. By "inserted" I mean "the Document node appears in the list of ancestor nodes of the bound element." To clarify, consider the following pseudocode: var elem = document.createElement("something"); elem.callMethodDefinedInXBL(); document.documentElement.appendChild(elem); As far as I can tell from the sXBL specification, the binding can be attached to "elem" when the node is created, so making the method call in line two of the pseudocode should be OK. Note that the binding constructor will also run when the binding is attached, before the node is inserted into the document. And it's not inconceivable that a binding may want to do something depending on where in the document the bound element ended up (given what the bindings used by many of Mozilla's UI widgets do, it seems rather likely). The problem is, there is no good way for the binding to be notified when the bound element is inserted into a document. DOM3 Mutation Events don't provide this functionality, unfortunately -- if the bound element is appended as a child to some other node and the other node is inserted in the document, the mutation event will fire on the other node. Since events don't propagate down the tree, the bound element will never see the mutation event. This could be worked around by watching events on the document itself, but all such approaches I can think of are rather inefficient (necessitating the need for walking all kids of the event target to find out whether we care about the event). Hence my proposal to fire an event (non-bubbling, probably) on the bound element itself when it's inserted into the document, whether directly or via one of its ancestors being inserted. -Boris
Received on Friday, 29 October 2004 17:34:30 UTC