Re: DOM Level 3 events

At 06:56 PM 1/18/2005 -0600, Boris Zbarsky wrote:

>Peter Sorotokin wrote:
>
>>>>>2)  That the implementation is keeping the event listeners for the two 
>>>>>types in
>>>>>     separate lists (is this desirable?  Should registering a listener 
>>>>> for both
>>>>>     types involved make it get the event twice?).
>>>>
>>>>You can do it per-listener rather than on per-list basis; but I'd keep 
>>>>two separate lists.
>>>
>>>
>>>In other words, a listener registered for both event names would indeed 
>>>get the event twice?
>>No, in this case each event listener entry in the list would have to 
>>store an event type for which it was registered (also would be needed for 
>>unregistering).
>
>I'm sorry, but I think you lost me.  Say I have an event listener named 
>"listener" and an event target named "target".  We have our two event 
>types "type1" and "type2".  I execute the following code:
>
>   target.addEventListener("type1", listener, false);
>   target.addEventListener("type2", listener, false);
>
>when the event fires, how many times will my listener's handleEvent method 
>be called?

Twice, IMHO. They are still different events - even if they are 
"equivalent". I think we'd get in trouble with the DOM otherwise.

>   Please note the provisions on addEventListener for registering 
> identical listeners.
>
>Further, what is the behavior of:
>
>   target.addEventListener("type1", listener, false);
>   target.removeEventListener("type2", listener, false);

Again, IMHO, you still have listener for type1.


>?
>
>The answers to these questions should be clearly documented in the 
>specification of what it means for the two event names to be "equivalent".

Agreed.

Peter


>-Boris

Received on Wednesday, 19 January 2005 06:43:36 UTC