-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)web-js-interopIssues that impact all js interopIssues that impact all js interop
Description
These docs: https://api.dart.dev/dart-js_interop/globalContext.html
Say globalContext can be treated like JS's globalThis.
But when compiling, self is used, which blows up in Node.
Replacing self with globalThis in the output fixes issues.
Seeing this both in the use of globalContext from js_interop and with the code generated with createJSInteropWrapper
diff --git a/out.js b/out.js
index 0c4c10f..fe9f8d3 100644
--- a/out.js
+++ b/out.js
@@ -2636,7 +2636,7 @@
},
main() {
A.print("Hello World!");
- type$.JSObject._as(self).exportValue = new A.main_closure(new A.Export()).call$0();
+ type$.JSObject._as(globalThis).exportValue = new A.main_closure(new A.Export()).call$0();
},
main_closure: function main_closure(t0) {
this.thing = t0;
@@ -3146,7 +3146,7 @@
call$0() {
var result,
t1 = type$.JSObject,
- t2 = t1._as(t1._as(self).Object),
+ t2 = t1._as(t1._as(globalThis).Object),
_jsExporter = t1._as(t2.create.apply(t2, [null]));
t2 = this.thing.get$printMessage();
if (typeof t2 == "function")Metadata
Metadata
Assignees
Labels
area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)web-js-interopIssues that impact all js interopIssues that impact all js interop