<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>13433</bug_id>
          
          <creation_ts>2011-07-28 21:47:17 +0000</creation_ts>
          <short_desc>Event handler IDL attributes need [TreatNonCallableAsNull]</short_desc>
          <delta_ts>2011-10-16 05:46:40 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>LC1 HTML5 spec</component>
          <version>unspecified</version>
          <rep_platform>Other</rep_platform>
          <op_sys>other</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://www.whatwg.org/specs/web-apps/current-work/#events</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          <dependson>13499</dependson>
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>arun</cc>
    
    <cc>bugs</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>cam</cc>
    
    <cc>ian</cc>
    
    <cc>jonas</cc>
    
    <cc>me</cc>
    
    <cc>mike</cc>
    
    <cc>Ms2ger</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
    
    <cc>travil</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>51695</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2011-07-28 21:47:17 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html
Multipage: http://www.whatwg.org/C#events
Complete: http://www.whatwg.org/c#events

Comment:
Using &quot;Function?&quot; for the on* IDL attribute type doesn&apos;t seem to match
implementations on setting

Posted from: 71.184.125.56
User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0a1) Gecko/20110721 Firefox/8.0a1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51697</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-07-28 21:49:12 +0000</bug_when>
    <thetext>In particular, per current spec text this will throw on setting:

  document.body.onclick = 3;

but what actually happens in Gecko is that the expando is just set to 3, and in Presto and WebKit this sets document.body.onclick to null....

I will probably implement this last in Gecko as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51699</commentid>
    <comment_count>2</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-07-28 21:50:32 +0000</bug_when>
    <thetext>Oh, and setting 

  document.body.onclick = {};

actually leaves it set to that value in Chrome and Safari, while it looks like it&apos;s still null in Opera.

What does IE do here?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51702</commentid>
    <comment_count>3</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-07-28 21:53:48 +0000</bug_when>
    <thetext>So do these need to accept &quot;any&quot; in the Web IDL and if it is not a Function it just sets it to null? That would be unfortunate.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51703</commentid>
    <comment_count>4</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2011-07-28 21:56:15 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; So do these need to accept &quot;any&quot; in the Web IDL and if it is not a Function it
&gt; just sets it to null? That would be unfortunate.

If this behaviour is needed, then &quot;cleaner&quot; may be to leave them as `Function?` but have some custom type coercion behaviour (specified by an extended attribute or some prose).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51704</commentid>
    <comment_count>5</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-07-28 22:01:40 +0000</bug_when>
    <thetext>Anne, that depends.  Again, what does IE do here?

Starting to throw an exception in situations where no UA does right now would seem to be a non-starter to me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51714</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-07-28 23:16:25 +0000</bug_when>
    <thetext>IE allows setting it to an object (e.g. window.XMLHttpRequest, {}, document, etc.) but setting it to 3 or &quot;string&quot; keeps the value as null. Seems like it matches WebKit?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51715</commentid>
    <comment_count>7</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2011-07-28 23:48:06 +0000</bug_when>
    <thetext>IE9&apos;s IDL attribute event handlers appear to accept Function, Object, Array, and DOM object instances, but nothing else (String, RegExp, Number, Boolean, etc.).

I&apos;m not sure why; I&apos;ll try to get back to you on this...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51717</commentid>
    <comment_count>8</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-07-28 23:56:02 +0000</bug_when>
    <thetext>&gt; but setting it to 3 or &quot;string&quot; keeps the value as null.

Keeps, or sets?  That is, if you set it to a Function and then set to 3, do you get null, or the function that you set it to first?

In any case, it sounds like throwing on non-Functions is a non-starter since no implementation does it...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51718</commentid>
    <comment_count>9</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-07-29 00:01:04 +0000</bug_when>
    <thetext>Sets, sorry.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51723</commentid>
    <comment_count>10</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-07-29 02:09:25 +0000</bug_when>
    <thetext>For what it&apos;s worth, my current plan for Gecko is to set the handler to the given object if the given object is callable, and set it to null otherwise.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51887</commentid>
    <comment_count>11</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2011-08-01 04:06:32 +0000</bug_when>
    <thetext>Is there a need for this assume-null-if-assigned-thing-is-wrong behaviour for any non-Function attributes?  (I.e. is it something we want to change in the normal ES-&gt;IDL conversion rules?)

Ian: can you file a bug on Web IDL if you need a mechanism to select this non-standard coercion behaviour, thanks.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51898</commentid>
    <comment_count>12</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-08-01 11:36:29 +0000</bug_when>
    <thetext>Filed bug 13499 on Web IDL.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51905</commentid>
    <comment_count>13</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-08-01 15:06:49 +0000</bug_when>
    <thetext>It&apos;s not even clear that we need this weirdness for all Function attributes.

Or are on* the only Function attributes around?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51926</commentid>
    <comment_count>14</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2011-08-01 21:33:37 +0000</bug_when>
    <thetext>I believe they are the only uses of Function.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51928</commentid>
    <comment_count>15</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2011-08-01 21:45:09 +0000</bug_when>
    <thetext>...the IE behavior I mentined in Comment 7 is happening due to an
implementation-specific binding. The intent of the binding is to store JS
functions, but due to implementation details, it also happens to store the
other types as well.

When an unsupported assignment is made to the IDL attribute, the currently
stored handler is thrown out and the property is re-set back to null.

We made an additional change to IE9 to _not_ support string assignments, which
is a behavior that existed in IE8.

I think we were going for a behavior match with HTML5 at the time.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51981</commentid>
    <comment_count>16</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-08-02 11:25:22 +0000</bug_when>
    <thetext>It seems this behavior is not just used for Function. I get the same behavior for EventListener. Is this a problem with callbacks?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51987</commentid>
    <comment_count>17</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2011-08-02 13:39:49 +0000</bug_when>
    <thetext>&gt; I get the same behavior for EventListener.

Tested how?  This script:

    try {
      document.addEventListener(3, &quot;load&quot;, false);
    } catch (e) {
      alert(e);
    }

shows a conversion failure exception in Gecko, as expected, and has all along.  So I doubt sites depend on it working, unlike the on* case.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51989</commentid>
    <comment_count>18</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-08-02 13:44:10 +0000</bug_when>
    <thetext>It does not throw in either Opera or WebKit. Not sure about IE.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51998</commentid>
    <comment_count>19</comment_count>
    <who name="Travis Leithead [MSFT]">travil</who>
    <bug_when>2011-08-02 16:17:34 +0000</bug_when>
    <thetext>Doesn&apos;t throw in IE9 either.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52030</commentid>
    <comment_count>20</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2011-08-02 22:58:29 +0000</bug_when>
    <thetext>Whether addEventListener should be defined as

  void addEventListener(in DOMString a, in EventListener b, in bool c);

or

  void addEventListener(in DOMString a, [FunkyNullHandling] in EventListener? b, in bool c);

I guess is more of a problem for DOM Core.  If we can go with the exception throwing mode, I think we should do so.

I don&apos;t think the handling of non-object values is something we particularly want to propagate for new APIs, either, so I would rather introduce an extended attribute to allow this behaviour only on specific attributes and operation arguments.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>52090</commentid>
    <comment_count>21</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-08-03 05:37:14 +0000</bug_when>
    <thetext>By the way, please prefix the features that should not be propagated with &quot;Legacy&quot; or &quot;Compat&quot; or some such. E.g. stringifying null to &quot;&quot; is an example of that I think.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>53948</commentid>
    <comment_count>22</comment_count>
    <who name="Michael[tm] Smith">mike</who>
    <bug_when>2011-08-04 05:34:44 +0000</bug_when>
    <thetext>mass-move component to LC1</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57522</commentid>
    <comment_count>23</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-09-29 21:01:34 +0000</bug_when>
    <thetext>This should presumably also be fixed everywhere else </thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57523</commentid>
    <comment_count>24</comment_count>
    <who name="">contributor</who>
    <bug_when>2011-09-29 21:02:20 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r6599.
Check-in comment: Event handler IDL attribute compatibility WebIDL fix.
http://html5.org/tools/web-apps-tracker?from=6598&amp;to=6599</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57549</commentid>
    <comment_count>25</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-09-30 09:03:06 +0000</bug_when>
    <thetext>Given how often we use event handler attributes in the platform

&quot;[TreatNonCallableAsNull] Function?&quot;

is really rather ugly. We can maybe not introduce a &quot;DOMEventHandler&quot; type or some such in Web IDL for this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57585</commentid>
    <comment_count>26</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-09-30 19:53:20 +0000</bug_when>
    <thetext>I&apos;m not particularly worried about the verbosity here. It&apos;s pretty harmless. But if the syntax changes, just pass this potato back to me before it gets resolved. :-)

(Reassigning to Anne per comment 23.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57613</commentid>
    <comment_count>27</comment_count>
    <who name="Ms2ger">Ms2ger</who>
    <bug_when>2011-10-01 09:09:19 +0000</bug_when>
    <thetext>XHR: bug 14351
IDB: bug 14352
File API: http://lists.w3.org/Archives/Public/public-webapps/2011OctDec/0010.html</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>57716</commentid>
    <comment_count>28</comment_count>
    <who name="Arun">arun</who>
    <bug_when>2011-10-03 18:45:24 +0000</bug_when>
    <thetext>(In reply to comment #27)
&gt; XHR: bug 14351
&gt; IDB: bug 14352
&gt; File API:
&gt; http://lists.w3.org/Archives/Public/public-webapps/2011OctDec/0010.html

Made the change in File API editor&apos;s draft:

http://dev.w3.org/2006/webapi/FileAPI/

(Goal is to arrive at a LCWD by October 12).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58279</commentid>
    <comment_count>29</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2011-10-16 03:49:09 +0000</bug_when>
    <thetext>(In reply to comment #25)
&gt; Given how often we use event handler attributes in the platform
&gt; 
&gt; &quot;[TreatNonCallableAsNull] Function?&quot;
&gt; 
&gt; is really rather ugly. We can maybe not introduce a &quot;DOMEventHandler&quot; type or
&gt; some such in Web IDL for this?

BTW I was thinking of making typedefs propagate the extended attributes that appear on them, so that this kind of thing could be factored out nicely.  For example:

  typedef [TreatNonCallableAsNull] Function? DOMEventHandler;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58280</commentid>
    <comment_count>30</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-10-16 05:46:40 +0000</bug_when>
    <thetext>Sounds great! Also useful for [TreatNullAs=...] and such.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>