- From: Domenic Denicola <d@domenic.me>
- Date: Sun, 22 Feb 2015 21:03:37 +0000
- To: "es-discuss@mozilla.org" <es-discuss@mozilla.org>
- CC: "public-script-coord@w3.org" <public-script-coord@w3.org>
(Cc'ing public-script-coord in case this answer gets more complicated in the presence of the window proxy/overriden this-in-global setup.)
Given code like
<script>
addEventListener("foo", function () { });
</script>
Is this supposed to be an Invoke(current global, "addEventListener", <"foo", function () {}>)?
Or is it just a Call(addEventListener, undefined, <"foo", function () {}>)?
What about if I added "use strict"; to the top of the script?
My suspicion was Invoke, but then I came up with another example that threw me off:
<script>
window.globalFunc = function () {
console.log("this", this);
};
</script>
<script>
"use strict";
globalFunc();
</script>
This gives `undefined`. (The result is the same if I also prepend "use strict"; to the top of the first script.) That nudges me toward the Call answer.
But under the Call answer, my first example would be broken since the implementation of `addEventListener` would not have a sensible `this` to operate on.
Anyway, I'm clearly missing something. What is it, and where are the relevant parts of the spec?
Received on Sunday, 22 February 2015 21:04:07 UTC