<?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>15358</bug_id>
          
          <creation_ts>2011-12-29 13:06:48 +0000</creation_ts>
          <short_desc>Use the new callback syntax for Function and event handler attributes.</short_desc>
          <delta_ts>2012-06-27 07:05:24 +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>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/#function</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P3</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>contributor</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>annevk</cc>
    
    <cc>cam</cc>
    
    <cc>dom</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>mounir</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
    
    <cc>w3c</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>62126</commentid>
    <comment_count>0</comment_count>
    <who name="">contributor</who>
    <bug_when>2011-12-29 13:06:48 +0000</bug_when>
    <thetext>Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html
Multipage: http://www.whatwg.org/C#function
Complete: http://www.whatwg.org/c#function

Comment:
Use the new callback syntax for Function and event handler attributes.

Posted from: 83.85.115.123 by annevk@opera.com
User agent: Opera/9.80 (Macintosh; Intel Mac OS X 10.7.2; U; en) Presto/2.10.229 Version/11.60</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>62127</commentid>
    <comment_count>1</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2011-12-29 13:11:21 +0000</bug_when>
    <thetext>In particular it should be something like this:

  callback EventHandlerListener = void (Event evt);
  typedef [TreatNonCallableAsNull] EventHandlerListener? EventHandler;

Event handler IDL attributes can then be defined as

  attribute EventHandler onclick;

The event handler attributes that take a different argument (onerror, others?) it probably makes sense to define a distinct callback so it is clear they are special from the IDL as well.

Cameron suggested EventListener elsewhere but that would be incompatible with the DOM (where it is a callback interface).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63504</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-02-01 00:58:54 +0000</bug_when>
    <thetext>Wouldn&apos;t this mean you can&apos;t assign a zero-argument method as a callback?

Surely the return value should be boolean, not void. What about things like onbeforeunload, where the value can be as string, too?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>63507</commentid>
    <comment_count>3</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2012-02-01 01:02:33 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; Wouldn&apos;t this mean you can&apos;t assign a zero-argument method as a callback?

No, zero-argument Functions can be passed in just like they could before with [Callback] interface.

&gt; Surely the return value should be boolean, not void. What about things like
&gt; onbeforeunload, where the value can be as string, too?

Either broaden the return type, or use separate callback definitions for the event handler IDL attributes that have different return types.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65346</commentid>
    <comment_count>4</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-03-12 13:24:15 +0000</bug_when>
    <thetext>*** Bug 15694 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65347</commentid>
    <comment_count>5</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-03-12 13:27:13 +0000</bug_when>
    <thetext>The new syntax for this is:

[TreatNonCallableAsNull]
callback EventHandler = any (Event event);

For window.onerror you will need something special, e.g.

[TreatNonCallableAsNull]
callback ErrorEventHandler = any (any... args);

To reference it you would use &quot;EventHandler?&quot;.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>65349</commentid>
    <comment_count>6</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-03-12 13:31:10 +0000</bug_when>
    <thetext>*** Bug 16320 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69284</commentid>
    <comment_count>7</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-06-20 09:23:19 +0000</bug_when>
    <thetext>*** Bug 17556 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69347</commentid>
    <comment_count>8</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2012-06-22 18:14:17 +0000</bug_when>
    <thetext>Would the difference between onclick and onerror be detectable in any way?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69357</commentid>
    <comment_count>9</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-06-24 06:22:47 +0000</bug_when>
    <thetext>As far as I can tell from reading IDL they would be treated identically in JavaScript so I suppose you might as well merge them and add a comment that in the common case an Event object is passed or some such.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69358</commentid>
    <comment_count>10</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2012-06-24 06:28:00 +0000</bug_when>
    <thetext>I think there is some value in keeping the types of onerror and the others different, just to help people reading the IDL.  For the same reason you use the most restrictive type for your attributes, rather than

  interface HTMLElement {
    ...
    readonly attribute any classList;
  };</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>69452</commentid>
    <comment_count>11</comment_count>
    <who name="Anne">annevk</who>
    <bug_when>2012-06-27 07:05:24 +0000</bug_when>
    <thetext>Seems this was fixed in http://html5.org/r/7146</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>