Skip to content

this value differs between dart2js and Dartium when calling a JS function. #25658

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kseo opened this issue Feb 3, 2016 · 2 comments
Closed
Assignees
Labels
web-js-interop Issues that impact all js interop

Comments

@kseo
Copy link

kseo commented Feb 3, 2016

I create a function JsTest and added showThis function to it. It simply prints this value to the console.

(function (mod) {
  if (typeof exports == "object" && typeof module == "object") // CommonJS
      module.exports = mod();
  else if (typeof define == "function" && define.amd) // AMD
      return define([], mod);
  else // Plain browser env
      this.JsTest = mod();
})(function () {
  "use strict";

  function JsTest() {
  }

  JsTest.showThis = function (name, value) {
    console.log(this);
  };

  return JsTest;
});

On the Dart side, I declared showThis function with @js annotation.

@JS('JsTest.showThis')
external void showThis();

void main() {
  showThis();
}

dart2js prints function JsTest() {} as I expected, but surprisingly Dartium prints Window.

@floitschG floitschG added the web-js-interop Issues that impact all js interop label Feb 3, 2016
@jacob314 jacob314 self-assigned this Jul 7, 2016
@jacob314
Copy link
Member

jacob314 commented Jul 7, 2016

The dart2js behavior is correct.

@jacob314 jacob314 mentioned this issue Jul 8, 2016
19 tasks
@jacob314
Copy link
Member

Verified that this was fixed a while ago. Regression test checked in here:
bcf224b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
web-js-interop Issues that impact all js interop
Projects
None yet
Development

No branches or pull requests

3 participants