W3C home > Mailing lists > Public > public-script-coord@w3.org > July to September 2013

RE: [WebIDL] Which realm should be used for coercing null/undefined this values to "the" global object?

From: Travis Leithead <travis.leithead@microsoft.com>
Date: Wed, 25 Sep 2013 00:52:48 +0000
To: David Bruant <bruant.d@gmail.com>, Boris Zbarsky <bzbarsky@MIT.EDU>
CC: "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-ID: <a348754fede243c6934546a1bf826d1e@BLUPR03MB245.namprd03.prod.outlook.com>
I checked, and the issues was indeed root-caused to our introduction of strict-mode, but not as a consequence of strict-mode. Rather, IE9 would convert undefined to the raw JS global and pass that to addEventListener in this scenario. The addEventListener code (never expecting to get the raw global) would throw. In IE10, this was fixed so that undefined correctly passes the window object. It was just a bug. :)

-----Original Message-----
From: David Bruant [mailto:bruant.d@gmail.com] 
Sent: Tuesday, September 24, 2013 12:32 AM
To: Boris Zbarsky
Cc: public-script-coord@w3.org
Subject: Re: [WebIDL] Which realm should be used for coercing null/undefined this values to "the" global object?

Le 24/09/2013 02:07, Boris Zbarsky a écrit :
> On 9/23/13 5:43 PM, David Bruant wrote:
>> Maybe IE9 has a form of self-hosted addEventListener, somthing like:
>>      EventTarget.prototype.addEventListener = function(type, listener){
>>          // use |this| as an object
>>      }
>>
>> IE9 has no support for strict mode, so the code would be non-strict 
>> and "this" has the global object as value by default when the 
>> function is called as a function (as opposed to as a method).
>
> It has the global object as default value no matter how it's called, 
> in non-strict code.  Simple testcase:
>
> <script>
>   (function f() {alert(this);}).call(undefined); </script>
>
> try it in your favorite browser.
Yep, I was mistaken. My bad.

David
Received on Wednesday, 25 September 2013 00:53:36 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:37:50 UTC