W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2001

Re: ECMAScript binding for EventListener

From: Dylan Schiemann <dylans@yahoo.com>
Date: Fri, 15 Jun 2001 09:30:31 -0700 (PDT)
Message-ID: <20010615163031.11606.qmail@web13502.mail.yahoo.com>
To: Jim Ley <jim@e-media.co.uk>
Cc: www-dom@w3.org
--- Jim Ley <jim@e-media.co.uk> wrote:

> My problem with it, is the unnecessaryness it takes
> a function, if you
> want it to be a function of an object, that doesn't
> matter, remember all
> functions are functions of the global object in
> ECMAScript
> I don't really see the functional difference between
> element.addEventListener("click",
> window.someEventHandler, false);
> and
> element.addEventListener("click",
> customObject.someEventHandler,false);
> The proposal is for:

There is a big difference between simply registering a
function as an event handler versus registering an
object method as an event handler.

> Which I don't really see as giving anything over and
> above the second
> example above, and I do not think adding things of
> little real value
> really has a place in the recommendation, such an
> extension to the DOM
> wouldn't cause any problems as I could see so
> implementors could be free
> to add such behaviour if they wish - but to force
> them to I see little
> sense - it'll just increase development and testing
> times leading to less
> compliant DOMs.

It requires the method which adds the event listener
to have an explicit reference to its instance.

The two options for this that I see are:
1) the object must know its identity. You must pass in
a reference to the instance of the object.

2) give the node on which the event is called a
pointer to the object.

It really breaks the spirit of o-o by having to resort
to one of these two options.

FWIW, that other browser company does make "this"
refer to the customObject, not the node on which the
event was fired. (not that following their
implementation is any meaningful reason)

> > The current behavior seems to have redundancy
> between
> > "this" and the first argument passed in an event.
> Not if the this isn't the DOM object in question,
> the examples above give
> different "this"'s to the the first argument.

I'm not sure I understand what you are saying here...
probably too many "this"... but don't the first and
second examples you gave both have "this" equal to the
element on which the event was fired when in the
context of the event handler function?

-Dylan Schiemann 

Do You Yahoo!?
Spot the hottest trends in music, movies, and more.
Received on Friday, 15 June 2001 12:30:33 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:08 UTC