structured clone: handle top-level booleans correctly

This commit is contained in:
Florian Dold 2021-04-07 15:52:57 +02:00
parent 2be1c3c8bd
commit 46056c416b
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B
2 changed files with 6 additions and 0 deletions

View File

@ -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);

View File

@ -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();
}