W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2012

Inconsistency of event handler idl attributes?, was Re: [proximity] HTML's WebIDL Function

From: Marcos Caceres <w3c@marcosc.com>
Date: Tue, 29 May 2012 15:51:49 +0100
Message-ID: <4FC4E285.6040605@marcosc.com>
To: www-dom@w3.org, Anne van Kesteren <annevk@opera.com>
(Moving to DOM List from device-apis list...)

On 28/05/2012 15:39, Anne van Kesteren wrote:
> On Mon, 28 May 2012 13:25:42 +0200, Marcos Caceres 
> <marcosscaceres@gmail.com> wrote:
>> While on other event handlers idl attributes (e.g., onload, onclick, 
>> etc.), the following works just fine:
>>
>> window.onload = {handleEvent: function(e){console.log(e)}}
>> window.onclick = {handleEvent: function(e){console.log(e)}}
>
> "[J]ust fine" is an overstatement. It works in Chrome (which is a bug) 
> and it does not work in Opera and Firefox.
So, you are correct: Opera and Firefox the above does not work.

However, the above is inconstant given that the following works in Opera:

var h = document.querySelector("h1");
var handler  = {}
window.document.onclick = handler;
handler.handleEvent = function(e){
h.innerHTML = "you mad bro?"
     }

See the following link for a more complete test, which demonstrates that 
.onclick works as expected on DOM Nodes:
http://jsfiddle.net/marcosc/VNFD6/8/

(Everything works as expected in Chrome and Safari, Firefox does 
register the listener, and Opera fires 2 out of 3 events, which shows 
that Opera has inconsistent behavior for two things that look pretty 
much identical from a developer's perspective... perhaps DOM Node's 
.onfoo are not classed as an "event handler IDL attribute"?)

Ideally, it would be good if everyone behaved consistently here 
(ideally, like Chrome/Safari IHMO).
Received on Tuesday, 29 May 2012 14:52:30 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:09 GMT