On 9/7/14, Mark Miller <[email protected]> wrote:
> On Sun, Sep 7, 2014 at 11:27 AM, Domenic Denicola <
> [email protected]> wrote:
>
>> I don't understand why this is any more surprising than any other
>> function that calls its callback with .call(something).
>>
>
> The issue is what the something should be, and which choices for something
> are surprising for what APIs.
>
>
>
>> It doesn't matter whether the callback is strict or not; .call(window),
>> which is what the spec does, will override it.
>>
>
> I don't understand what you're trying to say here. What will override what?
>
>
>>
>> As far as I can see this issue has absolutely nothing to do with strict
>> vs. sloppy.
>>
>
> As Andrea initially stated, this is a DOM-spec issue, not a JS issue, in
> that JS allows setTimeout to call the callback with WTF it wants. However,
> the purpose of setTimeout, etc, from the JS programmer's perspective, is to
> postpone some action to some future time. From this understanding, there's
> no reason to give the postponed action access to the global object. From a
> POLA perspective, there is thus strong reason not to.
>
If legacy compatibility is needed then setTimeout's callback function
must be called with the same window of setTimeout, just as with global
addEventListener.
<script>
"use strict"
addEventListener("click", function(ev){
console.log(this === window);
});
</script>
--
Garrett
@xkit
ChordCycles.com
garretts.github.io
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss