handleEvent DOM API breakage

Darin Adler darin at apple.com
Sat Oct 18 17:25:46 CEST 2003


On Oct 18, 2003, at 3:41 PM, David Faure wrote:

> After testing in Mozilla, IE (5 and 6), it is apparent that onLoad is 
> treated like a window event, setting "this" to "window" indeed.
>
> However for any other event, like e.g. onmousedown:
>
> In Mozilla: "this" is the window, so this.document works.
> In IE5/6: "this" is the body, so this.document works there too.
> In KHTML: "this" is the body. I guess this gets broken by your Safari 
> change,
> it would set it to the window in that case.

No, it's still the body even with the change. I tried your test page 
and saw the body, not the window. I think this is due to the 
NodeImpl::handleLocalEvents code path vs. the 
DocumentImpl::defaultEventHandler code path, but as I said the last 
time I looked at this was six months ago and I'm a bit fuzzy on the 
details.

> (My test on event.currentTarget showed that it's the window in 
> Mozilla, and non-implemented in IE5/6)
>
> Conclusion: <body onload> (and probably onunload) really appears to be 
> treated as a special case, as if it was an event on the window instead 
> of one on the body. Other events, though, should be treated as coming 
> from the body.

You are proposing that we match WinIE and not Mozilla. That sounds OK 
to me; WinIE is the de-facto standard.

But usually in cases like this where the browsers disagree and we don't 
have examples of specific web pages that require one or the other, I 
like to check with some experts too. I'd like to ask people on the 
Mozilla team like Doug Baron how they decided what to do what they did 
and ask notable DOM experts like Peter-Paul Koch what they think.

     -- Darin



More information about the Khtml-devel mailing list