diff --git a/CHANGELOG.md b/CHANGELOG.md index 093d36d4d7a3..2158df3a4bc6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ## Changelog ##### Unreleased +- Allowed cloning resizable `ArrayBuffer`s in the `structuredClone` polyfill - Fixed wrong export in `/(stable|actual|full)/instance/unshift` entries, [#1207](https://github.com/zloirock/core-js/issues/1207) ##### [3.28.0 - 2023.02.14](https://github.com/zloirock/core-js/releases/tag/v3.28.0) diff --git a/packages/core-js/modules/web.structured-clone.js b/packages/core-js/modules/web.structured-clone.js index 75621119c83f..96df46f262e6 100644 --- a/packages/core-js/modules/web.structured-clone.js +++ b/packages/core-js/modules/web.structured-clone.js @@ -147,7 +147,7 @@ var structuredCloneInternal = function (value, map) { var type = classof(value); var deep = false; - var C, name, cloned, dataTransfer, i, length, keys, key, source, target; + var C, name, cloned, dataTransfer, i, length, keys, key, source, target, options; switch (type) { case 'Array': @@ -302,11 +302,12 @@ var structuredCloneInternal = function (value, map) { if (!C && typeof value.slice != 'function') throwUnpolyfillable(type); // detached buffers throws in `DataView` and `.slice` try { - if (typeof value.slice == 'function') { + if (typeof value.slice == 'function' && !value.resizable) { cloned = value.slice(0); } else { length = value.byteLength; - cloned = new ArrayBuffer(length); + options = 'maxByteLength' in value ? { maxByteLength: value.maxByteLength } : undefined; + cloned = new ArrayBuffer(length, options); source = new C(value); target = new C(cloned); for (i = 0; i < length; i++) {