[Bug 18732] [Custom]: element upgrade algorithm does not preserve attributes, event listeners, references

https://www.w3.org/Bugs/Public/show_bug.cgi?id=18732

--- Comment #14 from Scott Miles <sjmiles@chromium.org> 2012-08-29 21:14:18 UTC ---
(In reply to comment #11)
> (In reply to comment #10)
> > (In reply to comment #9)
> > > I'd rather have some dictionary passed to register and it would contain
> > > the listeners which would be automatically registered.
> > > 
> > > 
> > > Something like
> > > 
> > > document.register("foobarelement", {
> > >   prototype: HTMLSpanElement,
> > >   listeners: {
> > >     click: function(evt) { /*do something*/ },
> > >     mouseover: function(evt) { /* do something else*/ };
> > >   }
> > > })
> > > 
> > 
> > Sweet. That should really cut down on the amount of things that we have to do
> > in "created" callback.
> 
> Oh. One problem -- how do I bind a listener to specific instance? I guess I
> can't, but that's what the "created" callback is for :)

(In reply to comment #9)
> I'd rather have some dictionary passed to register and it would contain
> the listeners which would be automatically registered.
> 
> 
> Something like
> 
> document.register("foobarelement", {
>   prototype: HTMLSpanElement,
>   listeners: {
>     click: function(evt) { /*do something*/ },
>     mouseover: function(evt) { /* do something else*/ };
>   }
> })
> 
> 
> 
> (And please don't say webkit's memory management can't handle that.)

(In reply to comment #11)
> (In reply to comment #10)
> > (In reply to comment #9)
> > > I'd rather have some dictionary passed to register and it would contain
> > > the listeners which would be automatically registered.
> > > 
> > > 
> > > Something like
> > > 
> > > document.register("foobarelement", {
> > >   prototype: HTMLSpanElement,
> > >   listeners: {
> > >     click: function(evt) { /*do something*/ },
> > >     mouseover: function(evt) { /* do something else*/ };
> > >   }
> > > })
> > > 
> > 
> > Sweet. That should really cut down on the amount of things that we have to do
> > in "created" callback.
> 
> Oh. One problem -- how do I bind a listener to specific instance? I guess I
> can't, but that's what the "created" callback is for :)

Events are normally automatically called in instance scope, yeah? 'this' inside
click should refer to the target element unless somebody done explicit
bindings.

But in any case, seems to me 'how to attach default listeners' is another
topic. 

What I'm concerned about is this: Bob the developer writes:

<x-awesome onclick="awesomeClick()"></x-awesome>

I'm 99.9% sure Bob wants that method to fire when that node is clicked, and
that he should not be concerned with how x-awesome is actually instantiated.

-- 
Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

Received on Wednesday, 29 August 2012 21:14:20 UTC