Skip to content

Commit 8571ad6

Browse files
committed
fix order of arguments validation in Array.prototype.flat polyfill
1 parent 5ac5073 commit 8571ad6

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- Fixed double `.return()` calling in case of throwing error in this method in the internal `iterate` helper that affected some polyfills
1313
- Fixed closing iterator on `IteratorValue` errors in the internal `iterate` helper that affected some polyfills
1414
- Fixed iterator closing in `Array.from` polyfill on failure to create array property
15+
- Fixed order of arguments validation in `Array.prototype.flat` polyfill
1516
- Fixed handling strings as iterables in `Iterator.{ zip, zipKeyed }` polyfills
1617
- Fixed some cases of iterators closing in `Iterator.{ zip, zipKeyed }` polyfills
1718
- Fixed a lack of early error in `Iterator.concat` polyfill on primitive as an iterator

packages/core-js/modules/es.array.flat.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ $({ target: 'Array', proto: true }, {
1313
var depthArg = arguments.length ? arguments[0] : undefined;
1414
var O = toObject(this);
1515
var sourceLen = lengthOfArrayLike(O);
16+
var depthNum = depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg);
1617
var A = arraySpeciesCreate(O, 0);
17-
flattenIntoArray(A, O, O, sourceLen, 0, depthArg === undefined ? 1 : toIntegerOrInfinity(depthArg));
18+
flattenIntoArray(A, O, O, sourceLen, 0, depthNum);
1819
return A;
1920
}
2021
});

0 commit comments

Comments
 (0)