Skip to content

Commit

Permalink
prevent some theoretical cases of breaking / observing the internal s…
Browse files Browse the repository at this point in the history
…tate by patching `Array.prototype[@@species]`
  • Loading branch information
zloirock committed Nov 28, 2021
1 parent 48d0b3f commit 7f6670f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
##### Unreleased
- Added a workaround for a UC Browser specific version bug with unobservable `RegExp#sticky` flag, [#1008](https://github.com/zloirock/core-js/issues/1008), [#1015](https://github.com/zloirock/core-js/issues/1015)
- Added handling of comments and specific spaces to `Function#name` polyfill, [#1010](https://github.com/zloirock/core-js/issues/1010), thanks [@ildar-shaimordanov](https://github.com/ildar-shaimordanov)
- Prevented some theoretical cases of breaking / observing the internal state by patching `Array.prototype[@@species]`
- Added iOS Safari 15.2 compat data mapping
- Added Electron 17.0 compat data mapping
- Updated Deno compat data mapping
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js/internals/array-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var setPrototypeOf = require('../internals/object-set-prototype-of');
var getOwnPropertyNames = require('../internals/object-get-own-property-names').f;
var defineProperty = require('../internals/object-define-property').f;
var arrayFill = require('../internals/array-fill');
var arraySlice = require('../internals/array-slice');
var arraySlice = require('../internals/array-slice-simple');
var setToStringTag = require('../internals/set-to-string-tag');
var InternalStateModule = require('../internals/internal-state');

Expand Down
17 changes: 17 additions & 0 deletions packages/core-js/internals/array-slice-simple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var global = require('../internals/global');
var toAbsoluteIndex = require('../internals/to-absolute-index');
var lengthOfArrayLike = require('../internals/length-of-array-like');
var createProperty = require('../internals/create-property');

var Array = global.Array;
var max = Math.max;

module.exports = function (O, start, end) {
var length = lengthOfArrayLike(O);
var k = toAbsoluteIndex(start, length);
var fin = toAbsoluteIndex(end === undefined ? length : end, length);
var result = Array(max(fin - k, 0));
for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
result.length = n;
return result;
};
2 changes: 1 addition & 1 deletion packages/core-js/internals/array-sort.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var arraySlice = require('../internals/array-slice');
var arraySlice = require('../internals/array-slice-simple');

var floor = Math.floor;

Expand Down
2 changes: 1 addition & 1 deletion packages/core-js/internals/clear-error-stack.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var uncurryThis = require('../internals/function-uncurry-this');
var arraySlice = require('../internals/array-slice');
var arraySlice = require('../internals/array-slice-simple');

var replace = uncurryThis(''.replace);
var split = uncurryThis(''.split);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
var classof = require('../internals/classof-raw');
var toIndexedObject = require('../internals/to-indexed-object');
var $getOwnPropertyNames = require('../internals/object-get-own-property-names').f;
var arraySlice = require('../internals/array-slice');
var arraySlice = require('../internals/array-slice-simple');

var windowNames = typeof window == 'object' && window && Object.getOwnPropertyNames
? Object.getOwnPropertyNames(window) : [];
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js/modules/es.string.split.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var advanceStringIndex = require('../internals/advance-string-index');
var toLength = require('../internals/to-length');
var toString = require('../internals/to-string');
var getMethod = require('../internals/get-method');
var arraySlice = require('../internals/array-slice');
var arraySlice = require('../internals/array-slice-simple');
var callRegExpExec = require('../internals/regexp-exec-abstract');
var regexpExec = require('../internals/regexp-exec');
var stickyHelpers = require('../internals/regexp-sticky-helpers');
Expand Down
2 changes: 1 addition & 1 deletion packages/core-js/modules/web.url.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var anInstance = require('../internals/an-instance');
var hasOwn = require('../internals/has-own-property');
var assign = require('../internals/object-assign');
var arrayFrom = require('../internals/array-from');
var arraySlice = require('../internals/array-slice');
var arraySlice = require('../internals/array-slice-simple');
var codeAt = require('../internals/string-multibyte').codeAt;
var toASCII = require('../internals/string-punycode-to-ascii');
var $toString = require('../internals/to-string');
Expand Down

0 comments on commit 7f6670f

Please sign in to comment.