From bb026fc12c3c2ad37f47f0919e484bddcdc3d291 Mon Sep 17 00:00:00 2001 From: Michał Gołębiowski Date: Mon, 1 Jun 2015 23:25:38 +0200 Subject: Core: Make jQuery objects iterable Make iterating over jQuery objects possible using ES 2015 for-of: for ( node of $( "
" ) ) { console.log( node.id ); // "narwhal" } Fixes gh-1693 --- src/core.js | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/core.js b/src/core.js index 88b9a3c5d..ba6eeceb8 100644 --- a/src/core.js +++ b/src/core.js @@ -425,6 +425,16 @@ jQuery.extend({ support: support }); +// JSHint would error on this code due to the Symbol not being defined in ES5. +// Defining this global in .jshintrc would create a danger of using the global +// unguarded in another place, it seems safer to just disable JSHint for these +// three lines. +/* jshint ignore: start */ +if ( typeof Symbol === "function" ) { + jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ]; +} +/* jshint ignore: end */ + // Populate the class2type map jQuery.each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { -- cgit v1.2.3