瀏覽代碼

Fix issues with ArrayBuffer when running inside VM

Marcel Mraz 1 年之前
父節點
當前提交
8a6e644fc0
共有 1 個文件被更改,包括 2 次插入1 次删除
  1. 2 1
      packages/excalidraw/fonts/wasm/woff2.bindings.ts

+ 2 - 1
packages/excalidraw/fonts/wasm/woff2.bindings.ts

@@ -6,6 +6,7 @@
  * 
  * CHANGELOG:
  * - replaced existing exports with default esm export (`export default Module;`)
+ * - replaced "instanceof ArrayBuffer" with "Object.prototype.toString.call(d) === "[object ArrayBuffer]", due to unreliability of different ArrayBuffer instances depending on the context (i.e. inside VM)
 
 The MIT License (MIT)
 
@@ -2780,7 +2781,7 @@ const Module = (function () {
           return str;
         },
         toWireType(destructors, value) {
-          if (value instanceof ArrayBuffer) {
+          if (Object.prototype.toString.call(d) === "[object ArrayBuffer]") {
             value = new Uint8Array(value);
           }
           let getLength;