aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichał Gołębiowski <m.goleb@gmail.com>2015-06-01 23:25:38 +0200
committerMichał Gołębiowski <m.goleb@gmail.com>2015-06-13 23:14:36 +0200
commitbb026fc12c3c2ad37f47f0919e484bddcdc3d291 (patch)
tree7ba8975dcfd6c912f8ecb71761648ad4a38efe9b /src
parent9c8a3ecdc46156afd8f93aa44b6e6aea7c52c049 (diff)
downloadjquery-bb026fc12c3c2ad37f47f0919e484bddcdc3d291.tar.gz
jquery-bb026fc12c3c2ad37f47f0919e484bddcdc3d291.zip
Core: Make jQuery objects iterable
Make iterating over jQuery objects possible using ES 2015 for-of: for ( node of $( "<div id=narwhal>" ) ) { console.log( node.id ); // "narwhal" } Fixes gh-1693
Diffstat (limited to 'src')
-rw-r--r--src/core.js10
1 files changed, 10 insertions, 0 deletions
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) {