Bug 17425 - Inconsistency of event handler idl attributes
Summary: Inconsistency of event handler idl attributes
Alias: None
Product: HTML WG
Classification: Unclassified
Component: HTML5 spec (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
Depends on:
Reported: 2012-06-05 19:07 UTC by Marcos Caceres
Modified: 2012-06-12 09:47 UTC (History)
4 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Marcos Caceres 2012-06-05 19:07:13 UTC
The HTML spec says that event handler idl attributes (e.g., onload) the should be set with using objects that implement the Function interface. However, DOM4 allows objects that implement EventListener to be used (e.g., addEventListener({handleEvent:...})). 

From a developer perspective, this is inconsistent in that there are two ways of doing conceptually the same thing. 

What is interesting is that Webkit-based browsers support both approaches (which is good, IMO), while IE and Moz don't. Opera is somewhere in the middle: today, it supports using EventListener interface on Nodes (e.g., element.onclick) but not on the Window object.  

For more details, please see: 
Comment 1 Ian 'Hixie' Hickson 2012-06-05 21:16:14 UTC
There doesn't seem to be much point in using objects here given that you can put attributes on Function objects.
Comment 2 Marcos Caceres 2012-06-06 10:17:39 UTC
(In reply to comment #1)
> There doesn't seem to be much point in using objects here given that you can
> put attributes on Function objects.

Yes, I agree. But then why do we need to define EventListener in DOM4 instead of just using Function? My concern is simply that we should use one or the other. Supporting two ways of doing the same thing has led to confusion in implementations (Opera's implementation for instance, which supports EventListener on some attributes, but not on others - though Anne claims they've now fixed this internally). Also, Chrome supports assigning either an Object or a Function.  

Supporting EventListener on event handler idl attributes would give us the best of both worlds (you can use a function or an object)... but that might upset non-webkit browsers. 

Having said that, I don't mind if we close this bug and keep the current inconsistant behaviour. I just wanted to raise it as I ran into this while I was creating some tests for a test suite.
Comment 3 Simon Pieters 2012-06-12 09:47:21 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:

Status: Rejected
Change Description: no spec change
Rationale: The current inconsistent behavior seems to be the shortest path to interop.