-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
.forEach
method to iterable DOM collections, #329
Showing
21 changed files
with
497 additions
and
417 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
require('../../modules/web.dom.for-each'); | ||
module.exports = require('../../modules/_array-for-each'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
require('../../modules/web.dom.for-each'); | ||
require('../../modules/web.dom.iterable'); | ||
var $iterators = require('../../modules/es.array.iterator'); | ||
module.exports = { | ||
keys: $iterators.keys, | ||
values: $iterators.values, | ||
entries: $iterators.entries, | ||
iterator: $iterators.values | ||
iterator: $iterators.values, | ||
forEach: require('../../modules/_array-for-each') | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var nativeForEach = [].forEach; | ||
var $forEach = require('./_array-methods')(0); | ||
var STRICT = require('./_strict-method')(nativeForEach, true); | ||
|
||
// 22.1.3.10 Array.prototype.forEach(callbackfn [, thisArg]) | ||
module.exports = STRICT ? nativeForEach : function forEach(callbackfn /* , thisArg */) { | ||
return $forEach(this, callbackfn, arguments[1]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// iterable DOM collections | ||
// flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods | ||
module.exports = { | ||
CSSRuleList: 0, | ||
CSSStyleDeclaration: 0, | ||
CSSValueList: 0, | ||
ClientRectList: 0, | ||
DOMRectList: 0, | ||
DOMStringList: 0, | ||
DOMTokenList: 1, | ||
DataTransferItemList: 0, | ||
FileList: 0, | ||
HTMLAllCollection: 0, | ||
HTMLCollection: 0, | ||
HTMLFormElement: 0, | ||
HTMLSelectElement: 0, | ||
MediaList: 0, | ||
MimeTypeArray: 0, | ||
NamedNodeMap: 0, | ||
NodeList: 1, | ||
PaintRequestList: 0, | ||
Plugin: 0, | ||
PluginArray: 0, | ||
SVGLengthList: 0, | ||
SVGNumberList: 0, | ||
SVGPathSegList: 0, | ||
SVGPointList: 0, | ||
SVGStringList: 0, | ||
SVGTransformList: 0, | ||
SourceBufferList: 0, | ||
StyleSheetList: 0, | ||
TextTrackCueList: 0, | ||
TextTrackList: 0, | ||
TouchList: 0 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,6 @@ | ||
'use strict'; | ||
var $export = require('./_export'); | ||
var $forEach = require('./_array-methods')(0); | ||
var STRICT = require('./_strict-method')([].forEach, true); | ||
var forEach = require('./_array-for-each'); | ||
|
||
$export($export.P + $export.F * !STRICT, 'Array', { | ||
// 22.1.3.10 / 15.4.4.18 Array.prototype.forEach(callbackfn [, thisArg]) | ||
forEach: function forEach(callbackfn /* , thisArg */) { | ||
return $forEach(this, callbackfn, arguments[1]); | ||
} | ||
}); | ||
// 22.1.3.10 Array.prototype.forEach(callbackfn [, thisArg]) | ||
$export($export.P + $export.F * ([].forEach != forEach), 'Array', { forEach: forEach }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var DOMIterables = require('./_dom-iterables'); | ||
var forEach = require('./_array-for-each'); | ||
var redefine = require('./_redefine'); | ||
var global = require('./_global'); | ||
|
||
for (var NAME in DOMIterables) { | ||
var Collection = global[NAME]; | ||
var proto = Collection && Collection.prototype; | ||
if (proto && !proto.forEach) redefine(proto, 'forEach', forEach); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { GLOBAL } from '../helpers/constants'; | ||
|
||
QUnit.test('forEach method on iterable DOM collections', assert => { | ||
let absent = true; | ||
const collections = [ | ||
'NodeList', | ||
'DOMTokenList' | ||
]; | ||
|
||
for (const name of collections) { | ||
const Collection = GLOBAL[name]; | ||
if (Collection) { | ||
absent = false; | ||
assert.isFunction(Collection.prototype.forEach, `${ name }::forEach is a function`); | ||
assert.same(Collection.prototype.forEach, Array.prototype.forEach, `${ name }::forEach is equal of Array::forEach`); | ||
} | ||
} | ||
|
||
if (absent) { | ||
assert.ok(true, 'DOM collections are absent'); | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
require('../modules/web.dom.for-each'); | ||
require('../modules/web.dom.iterable'); | ||
module.exports = require('../modules/_core'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
require('../modules/web.timers'); | ||
require('../modules/web.immediate'); | ||
require('../modules/web.dom.for-each'); | ||
require('../modules/web.dom.iterable'); | ||
module.exports = require('../modules/_core'); |