Re: sXBL issue -- bindings getting notified when the bound element is inserted into a document

Cameron McCormack wrote:
> So this is purely from an sXBL author's point of view?

Yes.

> but surely you could just check if it was still there if this mattered (with,
> for example, Node.compareDocumentPosition).

Surely, but this seems like a huge headache for authors.  Given the number of
XBL bindings used in the Mozilla user interface that require this information
(about 20% of the total, last I checked), it seems that it may be worth
providing this as part of the language instead of having binding authors
reimplement it every time (which they are likely to do incorrectly).

> I guess I don't see what is special about notifying the binding that the 
> bound element is inserted into the document.

Because binding authors apparently want to be able to walk the DOM around the
element the binding is attached to and do something based on the resulting
information (eg the radio binding in the Mozilla user interface looks for a
radiogroup containing it and registers with it; that sort of thing).

> To be inserted into the document, it would have to be not in the document
> tree beforehand.

Right.

> And if that is the case, the binding may as well use the 'bound' event to do
> whatever it needed to do.

That's assuming that bindings are only attached to elements that are in the 
document tree.  As long as we're talking about sXBL, where bindings just add 
shadow content this is reasonable.  In XBL2 or Mozilla XBL, where a binding can 
implement methods, it seems very odd for methods to appear and disappear based 
on whether a node is in a document (and even odder to have a node that has some 
methods, clone it, and have the clone not have the same methods).  By the way, 
Mozilla XBL currently has some very messed up semantics in this area, and it was 
while trying to clean those up that I ran into this issue.  I'd really like to 
avoid XBL2 ending up with a similar mess.

-Boris

Received on Friday, 18 March 2005 06:41:12 UTC