Skip to content

Commit

Permalink
fix omitting the result of proxing .return in `%IteratorHelperProto…
Browse files Browse the repository at this point in the history
…type%.return`, close #1116
  • Loading branch information
zloirock committed Aug 22, 2022
1 parent 4910371 commit 9e70176
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 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
- Considering `document.all` as an object in some missed cases, see [ECMAScript Annex B 3.6](https://tc39.es/ecma262/#sec-IsHTMLDDA-internal-slot)
- Avoiding unnecessary promise creation and validation result in `%WrapForValid(Async)IteratorPrototype%.return`, [proposal-iterator-helpers/215](https://github.com/tc39/proposal-iterator-helpers/pull/215)
- Fixed omitting the result of proxing `.return` in `%IteratorHelperPrototype%.return`, [#1116](https://github.com/zloirock/core-js/issues/1116)
- Fixed the order creation of properties of iteration result object of some iterators (`value` should be created before `done`)
- Fixed some cases of Safari < 13 bug - silent on non-writable array `.length` setting
- Fixed `ArrayBuffer.length` in V8 ~ Chrome 27-
Expand Down
12 changes: 7 additions & 5 deletions packages/core-js/internals/iterator-create-proxy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict';
var call = require('../internals/function-call');
var anObject = require('../internals/an-object');
var create = require('../internals/object-create');
var createNonEnumerableProperty = require('../internals/create-non-enumerable-property');
var defineBuiltIns = require('../internals/define-built-ins');
Expand Down Expand Up @@ -39,16 +38,19 @@ var createIteratorProxyPrototype = function (IS_ITERATOR) {
'return': function () {
var state = getInternalState(this);
var iterator = state.iterator;
var innerIterator = state.innerIterator;
state.done = true;
if (IS_ITERATOR) {
var returnMethod = getMethod(iterator, 'return');
return returnMethod ? call(returnMethod, iterator) : { value: undefined, done: true };
}
var innerIterator = state.innerIterator;
if (innerIterator) try {
iteratorClose(innerIterator, 'return');
} catch (error) {
return iteratorClose(iterator, 'throw', error);
}
var returnMethod = getMethod(iterator, 'return');
var result = returnMethod && call(returnMethod, iterator);
return IS_ITERATOR && returnMethod ? result : { value: returnMethod ? anObject(result).value : undefined, done: true };
iteratorClose(iterator, 'return');
return { value: undefined, done: true };
}
});

Expand Down

0 comments on commit 9e70176

Please sign in to comment.