W3C home > Mailing lists > Public > public-device-apis@w3.org > May 2012

[proximity] HTML's WebIDL Function

From: Marcos Caceres <marcosscaceres@gmail.com>
Date: Mon, 28 May 2012 12:25:42 +0100
To: "public-device-apis@w3.org" <public-device-apis@w3.org>, anssi.kostiainen@nokia.com
Cc: Anne van Kesteren <annevk@opera.com>
Message-ID: <CE34027B49D84CD5B69689FBB6A898B6@gmail.com>
I think the proximity spec should drop the use of HTML's Function callback in favour of DOM4's EventListener [1] callback interface (cc'ing Anne for guidance also).  

The problem with HTML's Function definition is that it's not fully "Web compatible" because it does not take into consideration objects that contain a handleEvent attribute (at least that is my understanding).

In other words, the following results in onuserproximity becoming "null" in our current specification:  

window.onuserproximity = {handleEvent: function(e){…}}

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)}}

var x = [];   
x["handleEvent"] = function(e){console.log(e)}
window.onclick = x;  

For legacy reasons, DOM4's EventListener callback caters for the above. For the sake of consistency with other event handler attributes, the proximity spec should behave the same.    

See the following to see legacy behaviour in action:

[1] http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#eventlistener
[2] http://dev.w3.org/2006/webapi/WebIDL/#dfn-callback-interface
Marcos Caceres
Received on Monday, 28 May 2012 11:26:17 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 19:32:37 UTC