Re: DOM 2 Event question...

My reading of this text, to use your example, is that:

buttonElt.setAttribute ( "onclick", "alert('foo')" );

can be implemented as (assuming that buttonElt instanceof EventTarget ==
true):

buttonElt.addEventListener ( "click", new Function ( "e",
"alert('foo')" ), false );

However, this seems problematic to me: if an implementation is free to
implement setAttribute in this manner, then would this support standard
attribute semantics; i.e., what would getAttribute() return after
setAttribute()?

Or does this text say "in addition to setting an attribute recognized to
represent an event handler, that implementors may/should/must (?) *also*
create and register an equivalent EventListener on the node"?

Regards,
Glenn Adams

----- Original Message -----
From: <Sam.Christiansen@trilogy.com>
To: <www-dom@w3.org>
Sent: Thursday, June 22, 2000 8:52 AM
Subject: DOM 2 Event question...


>
> In mainting compatibility with HTML 4.0 event listeners, the spec
says:
>
> "In order to achieve compatibility with HTML 4.0, implementors may
view the
> settings of attributes which represent event handlers as the creation
and
> registration of an EventListener on the Node.  The value of useCapture
> defaults to false.  This EventListener behaves in the same manner as
any
> other EventListeners which may be registered on the EventTarget."
>
> If the EventListener behaves in the same manner as any other
EventListener,
> then is the attribute which represents the event handler expected to
point
> to an object inmplementing the EventTarget interface (as opposed to a
> function)?
>
> ie, in HTML 4.0, I just put:  <BUTTON onclick="alert('foo')">
>
> with the new DOM 2 spec, would it look something like this?
>
> <BUTTON onclick="myEventHandler">
>
> where 'myEventHandler' implements the event target interface?  This
isn't
> backwards compatibility, and I just want to make sure that I
understand the
> spec correctly.
>
> Thanks,
>
> Sam Christiansen
> Trilogy Software
>
>

Received on Thursday, 22 June 2000 14:03:49 UTC