structured clone: handle top-level booleans correctly
This commit is contained in:
parent
2be1c3c8bd
commit
46056c416b
@ -24,7 +24,10 @@ function checkClone(t: ExecutionContext, x: any): void {
|
|||||||
test("structured clone", (t) => {
|
test("structured clone", (t) => {
|
||||||
checkClone(t, "foo");
|
checkClone(t, "foo");
|
||||||
checkClone(t, [1, 2]);
|
checkClone(t, [1, 2]);
|
||||||
|
checkClone(t, true);
|
||||||
|
checkClone(t, false);
|
||||||
checkClone(t, { x1: "foo" });
|
checkClone(t, { x1: "foo" });
|
||||||
|
checkClone(t, { x1: true, x2: false });
|
||||||
checkClone(t, new Date());
|
checkClone(t, new Date());
|
||||||
checkClone(t, [new Date()]);
|
checkClone(t, [new Date()]);
|
||||||
checkClone(t, undefined);
|
checkClone(t, undefined);
|
||||||
|
@ -180,6 +180,9 @@ export function internalStructuredRevive(val: any): any {
|
|||||||
if (typeof val === "string") {
|
if (typeof val === "string") {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
if (typeof val === "boolean") {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
if (!isPlainObject(val)) {
|
if (!isPlainObject(val)) {
|
||||||
throw Error();
|
throw Error();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user