Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

event object loses property values when being passed to function called with setTimeout

0 views
Skip to first unread message

Martin Honnen

unread,
Aug 6, 2006, 2:30:50 PM8/6/06
to

The test case
<http://home.arcor.de/martin.honnen/mozillaBugs/domLevel2/events/eventSetTimeout1.html>
has a p element with an onmousedown event handler attribute
onmousedown="doTest(event, false);"
where doTest outputs some properties of the event object and then uses
setTimeout(function () { doTest(evt, true); }, 10);
to call itself again passing in the same event object.
However Mozilla then loses event property values like clientX
respectively sets them to 0 as an example output if you click the
paragraph is

evt: [object MouseEvent]: type: mousedown; clientX: 199; clientY: 88

evt: [object MouseEvent]: type: mousedown; clientX: 0; clientY: 0

tested with Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1)
Gecko/20060806 Minefield/3.0a1.

If code passes the event object around without using setTimeout
<http://home.arcor.de/martin.honnen/mozillaBugs/domLevel2/events/eventSetTimeout2.html>
then everything is fine.

Does anyone know whether we have a bug on this? Can't find anything
searching for event and setTimeout.

The problem with clientX (or pageX) being 0 when the event object is
passed around with setTimeout exists also in Firefox 1.5 although there
the test case throws an exeption when accessing the type property of the
event object:

Error: uncaught exception: [Exception... "Component returned failure
code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMMouseEvent.type]" nsresult:
"0x80004005 (NS_ERROR_FAILURE)" location: "JS frame ::
http://home.arcor.de/martin.honnen/mozillaBugs/domLevel2/events/eventSetTimeout1.html
:: doTest :: line 16" data: no]


--

Martin Honnen
http://JavaScript.FAQTs.com/

Boris Zbarsky

unread,
Aug 6, 2006, 2:42:33 PM8/6/06
to
Martin Honnen wrote:
> where doTest outputs some properties of the event object and then uses
> setTimeout(function () { doTest(evt, true); }, 10);
> to call itself again passing in the same event object.

Properties of event objects are not defined by the DOM spec outside of event
dispatch....

> Does anyone know whether we have a bug on this? Can't find anything
> searching for event and setTimeout.

We probably have reports about events used after event dispatch...

This might or might not get fixed on trunk if we merge nsDOMEvent and nsEvent.

-Boris

0 new messages