handleEvent DOM API breakage
David Faure
faure at kde.org
Mon Oct 20 11:43:10 CEST 2003
On Sunday 19 October 2003 01:33, David Faure wrote:
> On Sunday 19 October 2003 01:25, Darin Adler wrote:
> > > 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.
Another related testcase:
<script>
name='window';
document.name='document';
function foo(evtname, t, evt) {
alert(evtname + ':\n' + 'this='+ t + ' ' + t.name +
'\ncurrentTarget=' + (evt?evt.currentTarget:'(evt is null)') );
}
function myonload() { foo('window.onload',this,event); }
window.onload=myonload;
function myresize() { foo('window.onresize',this,event); }
window.onresize=myresize;
function mymousedown() { foo('window.onmousedown',this,event); }
window.onmousedown=mymousedown;
</script>
Mozilla sets "this" to the window in all events, doesn't have support for "event"
(I don't know how to pass it from the caller as usually done with <body onload>)
IE-5 sets "this" to the window in all events, doesn't support currentTarget, and
doesn't seem to support onmousedown either.
OK, so they agree, and it makes sense. Please find attached the fix for this in KHTML.
Using currentTarget==0 is safe for this, since we know it never happened for
another reason. (KJS crashes as soon as a null "this" object is given to it, and we
had a kdWarning for it in ecma).
Do you agree to replace your added boolean with this fix? It's much simpler,
and doesn't break the DOM API.
Thanks.
--
David FAURE, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
-------------- next part --------------
An embedded message was scrubbed...
From: David Faure <faure at kde.org>
Subject: kdelibs/khtml
Date: Mon, 20 Oct 2003 10:37:30 +0200 (CEST)
Size: 4746
Url: http://mail.kde.org/mailman/private/khtml-devel/attachments/20031020/5ff62043/fwd-0001.eml
More information about the Khtml-devel
mailing list