From 95fc85d9f40e4c5cd2fd23b71b7cbbba108c7ae0 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Sat, 20 Aug 2022 01:04:40 +0700 Subject: [PATCH] fix `ArrayBuffer.length` in V8 ~ Chrome 27- --- CHANGELOG.md | 1 + packages/core-js-compat/src/data.mjs | 2 +- packages/core-js/internals/array-buffer.js | 4 ++-- tests/compat/tests.js | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 05b1a7f41667..21c212730390 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Avoid unnecessary promise creation and do not validate result in `%WrapForValid(Async)IteratorPrototype%.return`, [proposal-iterator-helpers/215](https://github.com/tc39/proposal-iterator-helpers/pull/215) - Fixed the order creation of properties of iteration result object of some iterators (`value` should be created before `done`) - Fixed some cases of Safari < 13 bug - silent on non-writable array `.length` setting +- Fixed `ArrayBuffer.length` in V8 ~ Chrome 27- - Relaxed condition of re-usage native `WeakMap` for internal states with multiple `core-js` copies - Availability cloning of `FileList` in the `structuredClone` polyfill extended to some more old engines versions - Some stylistic changes diff --git a/packages/core-js-compat/src/data.mjs b/packages/core-js-compat/src/data.mjs index 43f62a6ad972..b7d0e4cce2fb 100644 --- a/packages/core-js-compat/src/data.mjs +++ b/packages/core-js-compat/src/data.mjs @@ -448,7 +448,7 @@ export const data = { }, 'es.array-buffer.constructor': { bun: '0.1.1', - chrome: '26', + chrome: '28', edge: '14', firefox: '44', hermes: '0.1', diff --git a/packages/core-js/internals/array-buffer.js b/packages/core-js/internals/array-buffer.js index c743d77b9bdb..2ee3f126a017 100644 --- a/packages/core-js/internals/array-buffer.js +++ b/packages/core-js/internals/array-buffer.js @@ -197,9 +197,9 @@ if (!NATIVE_ARRAY_BUFFER) { new NativeArrayBuffer(); new NativeArrayBuffer(1.5); new NativeArrayBuffer(NaN); - return INCORRECT_ARRAY_BUFFER_NAME && !CONFIGURABLE_FUNCTION_NAME; + return NativeArrayBuffer.length != 1 || INCORRECT_ARRAY_BUFFER_NAME && !CONFIGURABLE_FUNCTION_NAME; })) { - /* eslint-enable no-new -- required for testing */ + /* eslint-enable no-new -- required for testing */ $ArrayBuffer = function ArrayBuffer(length) { anInstance(this, ArrayBufferPrototype); return new NativeArrayBuffer(toIndex(length)); diff --git a/tests/compat/tests.js b/tests/compat/tests.js index 42d241dc555d..a415d64ca181 100644 --- a/tests/compat/tests.js +++ b/tests/compat/tests.js @@ -544,7 +544,7 @@ GLOBAL.tests = { new ArrayBuffer(); new ArrayBuffer(1.5); new ArrayBuffer(NaN); - return ArrayBuffer.name == 'ArrayBuffer'; + return ArrayBuffer.length == 1 && ArrayBuffer.name == 'ArrayBuffer'; }], 'es.array-buffer.is-view': [ARRAY_BUFFER_VIEWS_SUPPORT, function () { return ArrayBuffer.isView;