Skip to content

Commit

Permalink
add .forEach method to iterable DOM collections, #329
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 9, 2017
1 parent 7f6ad09 commit db283a0
Show file tree
Hide file tree
Showing 21 changed files with 497 additions and 417 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1689,11 +1689,13 @@ Some DOM collections should have [iterable interface](https://heycam.github.io/w
#values() -> iterator
#keys() -> iterator
#entries() -> iterator
#forEach(fn(val, index, @), that) -> void
```
[*CommonJS entry points:*](#commonjs)
```js
core-js(/library)/web/dom-collections
core-js(/library)/fn/dom-collections/iterator
core-js/fn/dom-collections/for-each
```
[*Examples*](http://goo.gl/lfXVFl):
```js
Expand All @@ -1704,6 +1706,8 @@ for (let { id } of document.querySelectorAll('*')) {
for (let [index, { id }] of document.querySelectorAll('*').entries()) {
if (id) console.log(index, id);
}
document.querySelectorAll('*').forEach(it => console.log(it.id));
```
### Iteration helpers
Modules [`core.is-iterable`](https://github.com/zloirock/core-js/blob/v3/modules/core.is-iterable.js), [`core.get-iterator`](https://github.com/zloirock/core-js/blob/v3/modules/core.get-iterator.js), [`core.get-iterator-method`](https://github.com/zloirock/core-js/blob/v3/modules/core.get-iterator-method.js) - helpers for check iterability / get iterator in the `library` version or, for example, for `arguments` object:
Expand Down
2 changes: 2 additions & 0 deletions build/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ module.exports = {
'esnext.asap',
'esnext.observable',
'web.immediate',
'web.dom.for-each',
'web.dom.iterable',
'web.timers',
'core.get-iterator-method',
Expand All @@ -208,6 +209,7 @@ module.exports = {
'es.number.constructor',
'es.date.to-string',
'es.date.to-primitive',
'web.dom.for-each',
],

banner: '/**\n' +
Expand Down
Loading

0 comments on commit db283a0

Please sign in to comment.