-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
12 changed files
with
97 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,5 @@ | |
|
||
/dist | ||
/node_modules | ||
|
||
/test/node_smoke_tests/lib/ensure_iterability.js |
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,5 +1,6 @@ | ||
{ | ||
"preset": "jquery", | ||
|
||
"excludeFiles": [ "external", "src/intro.js", "src/outro.js" ] | ||
"excludeFiles": [ "external", "src/intro.js", "src/outro.js", | ||
"test/node_smoke_tests/lib/ensure_iterability.js" ] | ||
} |
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
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
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 @@ | ||
"use strict"; | ||
|
||
if ( typeof Symbol === "undefined" ) { | ||
console.log( "Symbols not supported, skipping the test..." ); | ||
process.exit(); | ||
} | ||
|
||
require( "./lib/ensure_iterability_es6" )(); |
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,13 @@ | ||
/* jshint esnext: true */ | ||
|
||
"use strict"; | ||
|
||
var assert = require( "assert" ); | ||
|
||
delete global.Symbol; | ||
require( "core-js" ); | ||
|
||
assert.strictEqual( typeof Symbol, "function", "Expected Symbol to be a function" ); | ||
assert.notEqual( typeof Symbol.iterator, "symbol", "Expected Symbol.iterator to be polyfilled" ); | ||
|
||
require( "./lib/ensure_iterability" )(); |
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,25 @@ | ||
/* jshint esnext: true */ | ||
|
||
"use strict"; | ||
|
||
var assert = require( "assert" ); | ||
|
||
module.exports = function ensureIterability() { | ||
require( "jsdom" ).env( "", function( errors, window ) { | ||
assert.ifError( errors ); | ||
|
||
var i, | ||
ensureJQuery = require( "./ensure_jquery" ), | ||
jQuery = require( "../../../dist/jquery.js" )( window ), | ||
elem = jQuery( "<div></div><span></span><a></a>" ), | ||
result = ""; | ||
|
||
ensureJQuery( jQuery ); | ||
|
||
for ( i of elem ) { | ||
result += i.nodeName; | ||
} | ||
|
||
assert.strictEqual( result, "DIVSPANA", "for-of doesn't work on jQuery objects" ); | ||
This comment has been minimized.
Sorry, 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
Typo! Fixed in #3584