(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?
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to