From ce955d00f6ba2bfe1d4121bf866a0151d541be80 Mon Sep 17 00:00:00 2001 From: Denis Pushkarev Date: Thu, 9 Mar 2023 02:35:54 +0700 Subject: [PATCH] fix `ToString` conversion / built-ins nature of some accessors --- CHANGELOG.md | 1 + .../internals/numeric-range-iterator.js | 35 +++++++++---------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a14115dc5bb..5bea2215e8df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Changelog ##### Unreleased - [`String.prototype.{ isWellFormed, toWellFormed }`](https://github.com/tc39/proposal-is-usv-string) marked as supported from V8 ~ Chrome 111 +- Fixed `ToString` conversion / built-ins nature of some accessors - Added Opera Android 74 compat data mapping ##### [3.29.0 - 2023.02.27](https://github.com/zloirock/core-js/releases/tag/v3.29.0) diff --git a/packages/core-js/internals/numeric-range-iterator.js b/packages/core-js/internals/numeric-range-iterator.js index 4ca598a022ea..10eef6a256a2 100644 --- a/packages/core-js/internals/numeric-range-iterator.js +++ b/packages/core-js/internals/numeric-range-iterator.js @@ -4,7 +4,7 @@ var createIteratorConstructor = require('../internals/iterator-create-constructo var createIterResultObject = require('../internals/create-iter-result-object'); var isNullOrUndefined = require('../internals/is-null-or-undefined'); var isObject = require('../internals/is-object'); -var defineProperties = require('../internals/object-define-properties').f; +var defineBuiltInAccessor = require('../internals/define-built-in-accessor'); var DESCRIPTORS = require('../internals/descriptors'); var INCORRECT_RANGE = 'Incorrect Iterator.range arguments'; @@ -53,7 +53,7 @@ var $RangeIterator = createIteratorConstructor(function NumericRangeIterator(sta start: start, end: end, step: step, - inclusiveEnd: inclusiveEnd, + inclusive: inclusiveEnd, hitsEnd: hitsEnd, currentCount: zero, zero: zero @@ -72,7 +72,7 @@ var $RangeIterator = createIteratorConstructor(function NumericRangeIterator(sta var step = state.step; var currentYieldingValue = start + (step * state.currentCount++); if (currentYieldingValue === end) state.hitsEnd = true; - var inclusiveEnd = state.inclusiveEnd; + var inclusiveEnd = state.inclusive; var endCondition; if (end > start) { endCondition = inclusiveEnd ? currentYieldingValue > end : currentYieldingValue >= end; @@ -85,25 +85,22 @@ var $RangeIterator = createIteratorConstructor(function NumericRangeIterator(sta } return createIterResultObject(currentYieldingValue, false); }); -var getter = function (fn) { - return { get: fn, set: function () { /* empty */ }, configurable: true, enumerable: false }; +var addGetter = function (key) { + defineBuiltInAccessor($RangeIterator.prototype, key, { + get: function () { + return getInternalState(this)[key]; + }, + set: function () { /* empty */ }, + configurable: true, + enumerable: false + }); }; if (DESCRIPTORS) { - defineProperties($RangeIterator.prototype, { - start: getter(function () { - return getInternalState(this).start; - }), - end: getter(function () { - return getInternalState(this).end; - }), - inclusive: getter(function () { - return getInternalState(this).inclusiveEnd; - }), - step: getter(function () { - return getInternalState(this).step; - }) - }); + addGetter('start'); + addGetter('end'); + addGetter('inclusive'); + addGetter('step'); } module.exports = $RangeIterator;