diff options
author | 2022-02-24 00:15:17 -0800 | |
---|---|---|
committer | 2022-02-24 00:15:17 -0800 | |
commit | 806e406b675f2827cec8c301c6bac3bd40211908 (patch) | |
tree | 719bba529c4bedb820cef1cac4aca75faaa601c6 /src/javascript/jsc/javascript.zig | |
parent | 3ad7c23221e1fb0fe0b53b1bdde8115f39089577 (diff) | |
download | bun-806e406b675f2827cec8c301c6bac3bd40211908.tar.gz bun-806e406b675f2827cec8c301c6bac3bd40211908.tar.zst bun-806e406b675f2827cec8c301c6bac3bd40211908.zip |
Expose TextEncoder & TextDecoder globally
Diffstat (limited to '')
-rw-r--r-- | src/javascript/jsc/javascript.zig | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/javascript/jsc/javascript.zig b/src/javascript/jsc/javascript.zig index 766f9f686..de15f6197 100644 --- a/src/javascript/jsc/javascript.zig +++ b/src/javascript/jsc/javascript.zig @@ -94,6 +94,9 @@ pub const GlobalClasses = [_]type{ Crypto.Class, Crypto.Prototype, + WebCore.TextEncoder.Constructor.Class, + WebCore.TextDecoder.Constructor.Class, + // The last item in this array becomes "process.env" Bun.EnvironmentVariables.Class, }; @@ -1314,6 +1317,7 @@ pub fn ConcurrentPromiseTask(comptime Context: type) type { event_loop: *VirtualMachine.EventLoop, allocator: std.mem.Allocator, promise: JSValue, + globalThis: *JSGlobalObject, pub fn createOnJSThread(allocator: std.mem.Allocator, globalThis: *JSGlobalObject, value: *Context) !*This { var this = try allocator.create(This); @@ -1322,6 +1326,7 @@ pub fn ConcurrentPromiseTask(comptime Context: type) type { .ctx = value, .allocator = allocator, .promise = JSValue.createInternalPromise(globalThis), + .globalThis = globalThis, }; js.JSValueProtect(globalThis.ref(), this.promise.asObjectRef()); return this; @@ -1344,7 +1349,7 @@ pub fn ConcurrentPromiseTask(comptime Context: type) type { var ctx = this.ctx; - js.JSValueUnprotect(VirtualMachine.vm.global.ref(), promise_value.asObjectRef()); + js.JSValueUnprotect(this.globalThis.ref(), promise_value.asObjectRef()); ctx.then(promise); } |