mirror of
https://github.com/hanzoai/core-js.git
synced 2026-09-24 16:58:15 +00:00
add detection of missed Webkit ~ Safari < 26.2 Iterator.prototype.flatMap bug case, close #1538
This commit is contained in:
+2
-1
@@ -25,6 +25,7 @@
|
||||
- `Promise.allSettledKeyed`
|
||||
- Throw a `RangeError` on finite unsafe integer `limit` in `Iterator.prototype.{ drop, take }`, following [tc39/ecma262/#3776](https://github.com/tc39/ecma262/pull/3776)
|
||||
- Use `PromiseResolve` semantics in `Promise.try`, following [tc39/ecma262/#3883](https://github.com/tc39/ecma262/pull/3883)
|
||||
- Added detection of missed [Webkit ~ Safari < 26.2 `Iterator.prototype.flatMap` bug](https://bugs.webkit.org/show_bug.cgi?id=297532) case, [#1538](https://github.com/zloirock/core-js/issues/1538)
|
||||
- Deno 2.9+ [*replaces* `Object.prototype.__proto__`](https://github.com/denoland/deno/pull/35192) instead of removing it, so the feature detection updated
|
||||
- Ensure opaque paths always roundtrip in URL polyfill (still without adding to feature detection), [whatwg/url#844](https://github.com/whatwg/url/pull/844)
|
||||
- Fixed possible crash on some keys in `Symbol.for`
|
||||
@@ -34,7 +35,7 @@
|
||||
- Improved the way of inner iterators cleaning in iterator helpers
|
||||
- Improved accuracy of `Math.{ asinh, cbrt, log1p }` polyfills with big and small values
|
||||
- Improved performance of `Uint8Array` base64 methods
|
||||
- Improved performance of `es.escape`
|
||||
- Improved performance of `escape`
|
||||
- Slight performance improvement for engines with native `Array#fill` on `ArrayBuffer` constructor and `%TypedArray%#fill`
|
||||
- Clarify supported Node versions in `package.json` of some missed packages (just to satisfy `publint`)
|
||||
- Compat data improvements:
|
||||
|
||||
@@ -15,10 +15,11 @@ var iteratorHelperWithoutClosingOnEarlyError = require('../internals/iterator-he
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=297532
|
||||
function throwsOnIteratorWithoutReturn() {
|
||||
try {
|
||||
// eslint-disable-next-line es/no-map, es/no-iterator, es/no-iterator-prototype-flatmap -- required for testing
|
||||
var it = Iterator.prototype.flatMap.call(new Map([[4, 5]]).entries(), function (v) { return v; });
|
||||
it.next();
|
||||
it['return']();
|
||||
// eslint-disable-next-line es/no-array-prototype-values, es/no-iterator-prototype-flatmap, es/no-iterator-prototype-find -- testing
|
||||
[1].values()
|
||||
.flatMap(function () { return [1]; })
|
||||
.find(function () { return true; });
|
||||
return false;
|
||||
} catch (error) {
|
||||
return true;
|
||||
}
|
||||
@@ -26,6 +27,7 @@ function throwsOnIteratorWithoutReturn() {
|
||||
|
||||
var FLAT_MAP_WITHOUT_THROWING_ON_INVALID_ITERATOR = !IS_PURE
|
||||
&& !iteratorHelperThrowsOnInvalidIterator('flatMap', function () { /* empty */ });
|
||||
|
||||
var flatMapWithoutClosingOnEarlyError = !IS_PURE && !FLAT_MAP_WITHOUT_THROWING_ON_INVALID_ITERATOR
|
||||
&& iteratorHelperWithoutClosingOnEarlyError('flatMap', TypeError);
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ QUnit.test('Iterator#flatMap', assert => {
|
||||
iter.return();
|
||||
}, 'iterator without `return` method');
|
||||
|
||||
assert.same([1].values().flatMap(() => [1]).find(() => true), 1, 'iterator without `return` method #2');
|
||||
|
||||
if (STRICT) {
|
||||
assert.throws(() => flatMap.call(undefined, () => { /* empty */ }), TypeError);
|
||||
assert.throws(() => flatMap.call(null, () => { /* empty */ }), TypeError);
|
||||
|
||||
@@ -3,9 +3,10 @@ import { STRICT, STRICT_THIS } from '../helpers/constants.js';
|
||||
|
||||
import Iterator from 'core-js-pure/es/iterator';
|
||||
import Map from 'core-js-pure/es/map';
|
||||
import values from 'core-js-pure/es/array/values';
|
||||
|
||||
QUnit.test('Iterator#flatMap', assert => {
|
||||
const { flatMap } = Iterator.prototype;
|
||||
const { flatMap, find } = Iterator.prototype;
|
||||
|
||||
assert.isFunction(flatMap);
|
||||
assert.arity(flatMap, 1);
|
||||
@@ -33,6 +34,8 @@ QUnit.test('Iterator#flatMap', assert => {
|
||||
iter.return();
|
||||
}, 'iterator without `return` method');
|
||||
|
||||
assert.same(find.call(flatMap.call(values([1]), () => [1]), () => true), 1, 'iterator without `return` method #2');
|
||||
|
||||
if (STRICT) {
|
||||
assert.throws(() => flatMap.call(undefined, () => { /* empty */ }), TypeError);
|
||||
assert.throws(() => flatMap.call(null, () => { /* empty */ }), TypeError);
|
||||
|
||||
Reference in New Issue
Block a user