Skip to content

Commit

Permalink
fix inheritance in typed array constructors wrappers, close #683
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Oct 31, 2019
1 parent 7e70e3c commit 3ae8db2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
@@ -1,6 +1,7 @@
## Changelog
##### Unreleased
- Don't detect Chakra-based Edge as Chrome in the `userAgent` parsing
- Fixed inheritance in typed array constructors wrappers, [#683](https://github.com/zloirock/core-js/issues/683)
- Added one more workaround for correct work of early `fetch` implementations with polyfilled `URLSearchParams`, [#680](https://github.com/zloirock/core-js/issues/680)

##### 3.3.5 - 2019.10.29
Expand Down
19 changes: 11 additions & 8 deletions packages/core-js/internals/typed-array-constructor.js
Expand Up @@ -24,6 +24,7 @@ var setSpecies = require('../internals/set-species');
var definePropertyModule = require('../internals/object-define-property');
var getOwnPropertyDescriptorModule = require('../internals/object-get-own-property-descriptor');
var InternalStateModule = require('../internals/internal-state');
var inheritIfRequired = require('../internals/inherit-if-required');

var getInternalState = InternalStateModule.get;
var setInternalState = InternalStateModule.set;
Expand Down Expand Up @@ -180,14 +181,16 @@ if (DESCRIPTORS) {
} else if (TYPED_ARRAYS_CONSTRUCTORS_REQUIRES_WRAPPERS) {
TypedArrayConstructor = wrapper(function (dummy, data, typedArrayOffset, $length) {
anInstance(dummy, TypedArrayConstructor, CONSTRUCTOR_NAME);
if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data));
if (isArrayBuffer(data)) return $length !== undefined
? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length)
: typedArrayOffset !== undefined
? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES))
: new NativeTypedArrayConstructor(data);
if (isTypedArray(data)) return fromList(TypedArrayConstructor, data);
return typedArrayFrom.call(TypedArrayConstructor, data);
return inheritIfRequired(function () {
if (!isObject(data)) return new NativeTypedArrayConstructor(toIndex(data));
if (isArrayBuffer(data)) return $length !== undefined
? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES), $length)
: typedArrayOffset !== undefined
? new NativeTypedArrayConstructor(data, toOffset(typedArrayOffset, BYTES))
: new NativeTypedArrayConstructor(data);
if (isTypedArray(data)) return fromList(TypedArrayConstructor, data);
return typedArrayFrom.call(TypedArrayConstructor, data);
}(), dummy, TypedArrayConstructor);
});

if (setPrototypeOf) setPrototypeOf(TypedArrayConstructor, TypedArray);
Expand Down

0 comments on commit 3ae8db2

Please sign in to comment.