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.
> 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.
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
<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
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!
The specification ended up aligning with WebKit: https://github.com/whatwg/webidl/commit/4043b051d492d4a2f21064f0edf91e642c5a6249 and https://lists.w3.org/Archives/Public/public-script-coord/2013OctDec/0412.html.