-
Notifications
You must be signed in to change notification settings - Fork 20.6k
Make jQuery collections for-of-able #1693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Isn't it a bit early to be doing this inside jQuery itself? If its just a line, the person using it knows whether their environment is going to be ES6 only. We don't know that. |
Yes, probably too early :) Just wanted to get general feedback. |
Hard to argue with one line of code! 😸 If you're in an environment where you know it's ES6, maybe a Phonegap/Cordova app in a year or two, it could be very handy. I don't think we'll keep this ticket open for that amount of time though? |
Agree |
I'd love to see this. Would make using jQuery with Babel more palatable. |
You know, I'm not actually against this. |
It'd be cool to have this natively in 3.0; even if simple. :) |
The biggest problem is size, I guess. The following: if ( typeof Symbol !== "undefined" && Symbol.iterator ) {
jQuery.fn[Symbol.iterator] = [][Symbol.iterator];
} increases the gzipped size by 32 bytes. Other forms seem larger. |
Since there is no definite decision yet, let's reopen for now. |
The concept has already been described by @jakearchibald in Dec 2004 for NodeList: http://jakearchibald.com/2014/iterators-gonna-iterate/#nodelist-iteration |
We've decided we're going to do it in 3.0.0. I'm taking it. |
Make iterating over jQuery objects possible using ES 2015 for-of: for ( node of $( "<div id=narwhal>" ) ) { console.log( node.id ); // "narwhal" } Fixes jquerygh-1693
PR: #2369 |
Make iterating over jQuery objects possible using ES 2015 for-of: for ( node of $( "<div id=narwhal>" ) ) { console.log( node.id ); // "narwhal" } Fixes jquerygh-1693
Make iterating over jQuery objects possible using ES 2015 for-of: for ( node of $( "<div id=narwhal>" ) ) { console.log( node.id ); // "narwhal" } Fixes jquerygh-1693
Make iterating over jQuery objects possible using ES 2015 for-of: for ( node of $( "<div id=narwhal>" ) ) { console.log( node.id ); // "narwhal" } Fixes jquerygh-1693
Make iterating over jQuery objects possible using ES 2015 for-of: for ( node of $( "<div id=narwhal>" ) ) { console.log( node.id ); // "narwhal" } Fixes jquerygh-1693
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
Chrome 38 added support for ES6
for-of
. I'm proposing that jQuery collections are made compatible with this statement, which can be achieved with this line (from discussion on Twitter):Live demo: http://jsbin.com/movuxu/1/edit (view in Chrome)
The text was updated successfully, but these errors were encountered: