<?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>24248</bug_id>
          
          <creation_ts>2014-01-09 05:15:08 +0000</creation_ts>
          <short_desc>Inconsistency between WebIDL callback function default this and JS strict mode default this</short_desc>
          <delta_ts>2014-01-10 05:37:53 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>WebIDL</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Nikhil">nsm.nikhil</reporter>
          <assigned_to name="Boris Zbarsky">bzbarsky</assigned_to>
          <cc>allen</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>dhtmlkitchen</cc>
    
    <cc>mike</cc>
    
    <cc>public-script-coord</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>98186</commentid>
    <comment_count>0</comment_count>
    <who name="Nikhil">nsm.nikhil</who>
    <bug_when>2014-01-09 05:15:08 +0000</bug_when>
    <thetext>http://www.w3.org/TR/WebIDL/#es-invoking-callback-functions

When a JS callback is invoked, WebIDL specifies default `this` to be `null`, but JS strict mode functions require that `this` be `undefined`.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98236</commentid>
    <comment_count>1</comment_count>
    <who name="Allen Wirfs-Brock">allen</who>
    <bug_when>2014-01-10 00:25:34 +0000</bug_when>
    <thetext>(In reply to Nikhil from comment #0)
&gt; http://www.w3.org/TR/WebIDL/#es-invoking-callback-functions
&gt; 
&gt; When a JS callback is invoked, WebIDL specifies default `this` to be `null`,
&gt; but JS strict mode functions require that `this` be `undefined`.

That isn&apos;t  exactly true. See step 1 of http://www.ecma-international.org/ecma-262/5.1/#sec-10.4.3 Strict mode functions accept whatever is passed to them as a thisValue without modifying it.

It&apos;s true that the function call operator http://www.ecma-international.org/ecma-262/5.1/#sec-11.2.3 passes undefined as the thisValue (step 7.a) but other means of function invocation (the call/apply functions) can pass null as the thisValue to a function.

BTW, I&apos;m not arguing against the proposed change (I&apos;m reserving judgement on that), just saying that it isn&apos;t an ES requirement one way or the other.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98237</commentid>
    <comment_count>2</comment_count>
    <who name="Cameron McCormack">cam</who>
    <bug_when>2014-01-10 00:33:04 +0000</bug_when>
    <thetext>I think Nikhil is only referring to the cases where you don&apos;t explicitly provide a this value, e.g. by doing f() or f.call() or f.apply().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98239</commentid>
    <comment_count>3</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-01-10 00:44:26 +0000</bug_when>
    <thetext>Conceptually, this is meant for cases when no this value is being explicitly provided to a function call, which should act just like this:

  var f = theFunctionIWasGiven;
  f();

or

  f.call();</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98243</commentid>
    <comment_count>4</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-01-10 03:15:03 +0000</bug_when>
    <thetext>https://github.com/heycam/webidl/commit/b495c5e1e63db9b3775e5ad48cc6518a46cc0cfc</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98244</commentid>
    <comment_count>5</comment_count>
    <who name="Garrett">dhtmlkitchen</who>
    <bug_when>2014-01-10 03:19:08 +0000</bug_when>
    <thetext>&quot;When any callback is called, call the callback&apos;s internal [[Call]] method, passing undefined as the this value.&quot;

That takes care of bound functions, too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>98247</commentid>
    <comment_count>6</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2014-01-10 05:37:53 +0000</bug_when>
    <thetext>Some callbacks are in fact called with some other this value.  For example, event handlers and callable event listeners are called with the event target as the this value.  So always passing undefined wouldn&apos;t be correct either.

Of course if the callee is a bound function it&apos;ll just ignore the this value passed to [[Call]], so they work no matter what.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>