Skip to content

Commit 99da3ba

Browse files
committed
fix a typo in the structuredClone feature detection, close #1106
1 parent bba906e commit 99da3ba

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
## Changelog
22
##### Unreleased
3+
- Fixed a typo in the `structuredClone` feature detection, [#1106](https://github.com/zloirock/core-js/issues/1106)
34
- Added Opera Android 70 compat data mapping
45

56
##### [3.23.4 - 2022.07.10](https://github.com/zloirock/core-js/releases/tag/v3.23.4)

packages/core-js/modules/web.structured-clone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var checkErrorsCloning = function (structuredCloneImplementation, $Error) {
6969
return !fails(function () {
7070
var error = new $Error();
7171
var test = structuredCloneImplementation({ a: error, b: error });
72-
return !(test && test.a === test.b && test.a instanceof $Error && test.stack === error.stack);
72+
return !(test && test.a === test.b && test.a instanceof $Error && test.a.stack === error.stack);
7373
});
7474
};
7575

tests/compat/tests.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,11 +1858,20 @@ GLOBAL.tests = {
18581858
'web.set-interval': TIMERS,
18591859
'web.set-timeout': TIMERS,
18601860
'web.structured-clone': function () {
1861-
var error = new Error();
1862-
var test = structuredClone({ a: error, b: error });
1863-
if (!(test && test.a === test.b && test.a instanceof Error && test.stack === error.stack)) return false;
1864-
test = structuredClone(new AggregateError([1], 'a', { cause: 3 }));
1865-
return test.name == 'AggregateError' && test.errors[0] == 1 && test.message == 'a' && test.cause == 3;
1861+
function checkErrorsCloning(structuredCloneImplementation, $Error) {
1862+
var error = new $Error();
1863+
var test = structuredCloneImplementation({ a: error, b: error });
1864+
return test && test.a === test.b && test.a instanceof $Error && test.a.stack === error.stack;
1865+
}
1866+
1867+
function checkNewErrorsCloningSemantic(structuredCloneImplementation) {
1868+
var test = structuredCloneImplementation(new AggregateError([1], 'message', { cause: 3 }));
1869+
return test.name == 'AggregateError' && test.errors[0] == 1 && test.message == 'message' && test.cause == 3;
1870+
}
1871+
1872+
return checkErrorsCloning(structuredClone, Error)
1873+
&& checkErrorsCloning(structuredClone, DOMException)
1874+
&& checkNewErrorsCloningSemantic(structuredClone);
18661875
},
18671876
// TODO: Remove this module from `core-js@4` since it's split to submodules
18681877
'web.timers': TIMERS,

0 commit comments

Comments
 (0)