W3C home > Mailing lists > Public > www-archive@w3.org > April 2012

Archiving Cameron's feedback on Web IDL comments LC-95 and LC-98

From: Arthur Barstow <art.barstow@nokia.com>
Date: Mon, 2 Apr 2012 09:31:34 -0400
Cc: www-archive <www-archive@w3.org>
To: Cameron McCormack <cam@mcc.id.au>
Message-Id: <6819D54E-B56B-471B-A97E-D796909FC79C@nokia.com>
Hi Cameron - here is the feedback you provided to me re Web IDL comments LC-95 and LC-98 <http://dev.w3.org/2006/webapi/WebIDL/lc3.txt>.

LC-95 relates to providing built-in support to the Web IDL language for a common construct that will be used for event listener attributes in a variety of specifications.  At the time of the bug being raised, event listener attributes had to be written like

 callback Function = any (Event event);
 [TreatNonCallableAsNull] attribute Function? onclick;
 [TreatNonCallableAsNull] attribute Function? onmousedown;
 [TreatNonCallableAsNull] attribute Function? onmouseup;

Ms2ger's argument was that because [TreatNonCallableAsNull] Function? and callbacks in general were to be used just for  event listener attributes, it would be better to add this as built-in functionality, such as

 attribute eventhandler onclick;
 attribute eventhandler onmousedown;
 attribute eventhandler onmouseup;

My argument was that callbacks should be used for things other than event listener attributes (the fundamental disagreement of LC-98), and that building in the concept of event handlers to Web IDL seemed like a layering violation.  My compromise solution was to allow [TreatNonCallableAsNull] to be specified on a callback, to suggest a callback to be defined in either DOM or HTML, to reduce the amount of IDL needed:

 /* in either the DOM or HTML spec */
 [TreatNonCallableAsNull] callback EventHandler = any (Event event);

 /* in specs defining event handler attributes */
 attribute EventHandler onclick;
 attribute EventHandler onmousedown;
 attribute EventHandler onmouseup;

This seemed concise enough to me.  As yet Ms2ger has not indicated whether this compromise solution is acceptable.

The mail where I proposed this solution is:


LC-98 relates to whether IDL callbacks should be used for anything other than event listener attributes.  There was a sizable disagreement in what we should recommend for other specifications wrt callbacks and whether objects like ({ handleEvent: function() { ... } }) in JS should be considered valid callbacks in general or just for DOM Events' addEventListener/removeEventListener.  That was discussed in this thread:


Jonas Sicking and Olli Pettay from Mozilla were the main proponents of allowing the object-with-property form as a callback in all APIs, whereas others argued for allowing object-with-property just for the DOM Events case because Web content relies on that.  I attempted to make a reasoned decision here:


Although Ms2ger did not participate in the thread, he raised the LC-98 bug to add a warning to Web IDL against using callbacks for anything other than the DOM Events case, which would effectively route around the decision I made in the thread.  Since it was inconsistent with that decision, I declined to make the suggested change.  I asked Ms2ger to respond on that thread with arguments against my analysis but so far no arguments have been forthcoming.

Received on Monday, 2 April 2012 13:32:10 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:44:03 UTC