diff options
author | Florian Dold <florian@dold.me> | 2021-04-07 15:52:57 +0200 |
---|---|---|
committer | Florian Dold <florian@dold.me> | 2021-04-07 15:52:57 +0200 |
commit | 46056c416b51b783d1b9c88385aba0d293021524 (patch) | |
tree | ea381ebdf1aad8bdaeeb13625423f99634fc5f96 /packages | |
parent | 2be1c3c8bd78b501ddf3a0b989f954f9163b3702 (diff) | |
download | wallet-core-46056c416b51b783d1b9c88385aba0d293021524.tar.xz |
structured clone: handle top-level booleans correctly
Diffstat (limited to 'packages')
-rw-r--r-- | packages/idb-bridge/src/util/structuredClone.test.ts | 3 | ||||
-rw-r--r-- | packages/idb-bridge/src/util/structuredClone.ts | 3 |
2 files changed, 6 insertions, 0 deletions
diff --git a/packages/idb-bridge/src/util/structuredClone.test.ts b/packages/idb-bridge/src/util/structuredClone.test.ts index ed404c6be..352c2c30b 100644 --- a/packages/idb-bridge/src/util/structuredClone.test.ts +++ b/packages/idb-bridge/src/util/structuredClone.test.ts @@ -24,7 +24,10 @@ function checkClone(t: ExecutionContext, x: any): void { test("structured clone", (t) => { checkClone(t, "foo"); checkClone(t, [1, 2]); + checkClone(t, true); + checkClone(t, false); checkClone(t, { x1: "foo" }); + checkClone(t, { x1: true, x2: false }); checkClone(t, new Date()); checkClone(t, [new Date()]); checkClone(t, undefined); diff --git a/packages/idb-bridge/src/util/structuredClone.ts b/packages/idb-bridge/src/util/structuredClone.ts index 4ba97dd7a..181e9ca0e 100644 --- a/packages/idb-bridge/src/util/structuredClone.ts +++ b/packages/idb-bridge/src/util/structuredClone.ts @@ -180,6 +180,9 @@ export function internalStructuredRevive(val: any): any { if (typeof val === "string") { return val; } + if (typeof val === "boolean") { + return val; + } if (!isPlainObject(val)) { throw Error(); } |