-
-
Save cowboy/503362 to your computer and use it in GitHub Desktop.
// Plugin released: | |
// http://benalman.com/projects/jquery-misc-plugins/#each2 |
James, I was thinking of releasing this as a standalone "jQuery fast .each" plugin, with code pretty much just as it is in this gist, and with the callback signature fn.call( dom_elem, i, jq_object )
. Would you object to that? (I don't want to step on your toes here)
I also definitely think that this should be considered for inclusion in core, with Resig making whatever decision regarding its signature/context if necessary, should it ever get to that point. I personally feel that changing jQuery's .each
signature from fn.call( dom_elem, i, dom_elem )
to fn.call( dom_elem, i, jq_object )
would be acceptable, but that's obviously not my call.
Ok, major correction.. this is going to be WAY slower than the core .each
in scenarios where the user doesn't need a jQuery object inside the callback... so it should definitely be a separate method. See http://jsperf.com/jquery-each-vs-quickeach/2
Ok, pluginized and released!
Mike, any time I post/release a plugin, if I can make it backwards-compatible with older jQuery versions easily I will.. Since
$([])
is a backwards-compatible way of "selecting" an empty set, I'll use that. Of course, for older jQueries, selecting document won't really consuming a whole lot of memory, but still.. that's how I roll!