Bug 95566 - WebKit accepts event listeners in onfoo attributes while no other browser does
Summary: WebKit accepts event listeners in onfoo attributes while no other browser does
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-08-31 06:45 PDT by Kyle Huey (Mozilla Developer)
Modified: 2022-05-30 00:28 PDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kyle Huey (Mozilla Developer) 2012-08-31 06:45:32 PDT
http://people.mozilla.org/~khuey/test-event-handlers.html

Gecko and Presto alert null once.
Trident alerts Object once.
WebKit alerts Object and ohai.

Gecko and Presto treat assigning an object to an onfoo property as assigning null to it (which is correct per-spec, as far as I can tell).
Trident does some crazy thing where it allows the onfoo property to be set but doesn't actually invoke the handleEvent function.
WebKit allows the onfoo property to be set and the event listener is fired.
Comment 1 Alexey Proskuryakov 2012-08-31 10:03:06 PDT
> which is correct per-spec, as far as I can tell

Could you please quote the spec you're looking at? For example, DOM 2 Events explicitly says that "implementors may view the setting of attributes which represent event handlers as the creation and registration of an EventListener on the EventTarget".

I agree that we should strongly consider matching other browsers, but spec story seems unclear here.

Also, it's a non-trivial question which objects should be considered callable (cf. for example bug 40012), which is why I'm interested in the exact text.
Comment 2 Kyle Huey (Mozilla Developer) 2012-08-31 10:08:53 PDT
HTML defines the relevant properties on Window.[0]

attribute EventHandler onabort;
...
attribute EventHandler onload;

Where EventHandler is defined as [1]

[TreatNonCallableAsNull]
callback EventHandlerNonNull = any (Event event);
typedef EventHandlerNonNull? EventHandler;

As far as a definition of what constitutes callable, I don't know.  I would assume that's in ES somewhere, if it's defined.

[0] http://www.whatwg.org/specs/web-apps/current-work/multipage/browsers.html#window
[1] http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler
Comment 3 Ms2ger (he/him; ⌚ UTC+1/+2) 2012-08-31 10:25:14 PDT
<ap> Ms2ger: care to quote any spec at all?
<Ms2ger> Sure
<ap> Ms2ger: and if that spec disagrees with previous spec, be sure to explain in detail why that was OK
<Ms2ger> http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler
<Ms2ger> And http://dev.w3.org/2006/webapi/WebIDL/#TreatNonCallableAsNull
<Ms2ger> The spec disagrees with the previous spec because the previous spec wasn't implemented
<Ms2ger> Except by webkit, apparently
Comment 4 Ahmad Saleem 2022-05-29 08:52:28 PDT
I searched the URL on Wayback Archive Machine and then created following fiddle:

Link - https://jsfiddle.net/ahp68r14/

Upon running, it just fire once [object Object] and it matches with Chrome Canary 104 and Firefox Nightly 102 output.

Since it matches with other browsers, should this be closed? Thanks!