> I don’t see Element.hasEvent anywhere in there.  I think it would be 
> better that addEvent did not allow duplicate events being added to it.
> Each event should be unique and should check to see that the function
> being added to the element doesn’t already exist
 
I don't agree at all.

First of all, if you have designed your app so it has to - due to some
event like ajax - continuously re-add events, then this is a design flaw.
You should consider using event delegation on the parent element and not
add events time and time again.

There are also many legitimate cases where multiple event callbacks are
useful to fire.

eg 1. you are using a class that allows the use of placeholder="" on
inputs that don't support it. This will typically involve onFocus,
onBlur and onChange events that deal with the default behaviour. That
does not mean to say you wouldn't want to add form validation on blur /
change that looks ate the input and acts accordingly, w/o having to do
so through the placeholder class. 

eg 2. on page admining. you may have mouseenter event that does an
effect for a normal user and add another effect, say offer an edit &
delete buttons for an admin on top of the effect. the admin module code
needs to be separate so you cannot keep it in the code that is public.
result: 2 mouseover events on the same element.

This is a feature and a useful one - else we'd still be doing a simple
element.onclick = function() { } instead.

Best regards,
-- 
Dimitar Christoff <[email protected]> 

blog: http://fragged.org/  twitter: @D_mitar 

Reply via email to