Re: Cloning XBL bound elements

Cameron McCormack wrote:
> Jonas Sicking:
>> Yes, that is probably how I would interpret the spec now, although it's 
>> not very explicit. This is Option A in my original email. However just 
>> leaving it at that I think would be a severe limitation on what you 
>> could implement using XBL2 since you couldn't keep any private state 
>> while still working with .clone().
> 
> You might be able to do it with a UserDataHandler that responds to
> NODE_CLONED (assuming you have DOM 3 Core).

Like I said in my original posting, that won't work with state that you 
need to keep private. Basically here is what would fail:

You have a binding that keeps some private data that needs to be copied 
when the element is cloned, say the number of checked items in the 
shadowtree.

In order to deal with cloning the binding would set up a UserDataHandler 
on the original node at the time when the binding is attached.

When the UserDataHandler is notified that the element has been cloned 
the handler is given a reference to the original element and to the 
clone. However, you are not given a copy of the private data of any of 
the two elements. Since the binding on the original element is the one 
to set up the UserDataHandler it can give it at construction time a 
reference to the original elements private data, but there is no way to 
get to the clones private data.

So in order to set the private data in the clones binding the binding 
has to expose some API that lets to set the private data directly. 
However this would mean that the data is no longer private and anyone 
could at any time change it.

/ Jonas

Received on Thursday, 10 May 2007 00:04:42 UTC