]> source.dussan.org Git - jquery.git/commitdiff
Core: change jQuery.each and jQuery#each signatures
authorOleg Gaidarenko <markelog@gmail.com>
Tue, 17 Feb 2015 07:09:54 +0000 (10:09 +0300)
committerOleg Gaidarenko <markelog@gmail.com>
Thu, 19 Feb 2015 08:31:55 +0000 (11:31 +0300)
(cherry-picked from 2380028ec4a6a77401b867a51de26a3cb8e8d311)
Fixes gh-2090
Closes gh-2097

src/core.js

index 9eb2ac5fc479d82cbd6f525439a4f70367e84995..21a995f382711bc4892faff071163e155a61507e 100644 (file)
@@ -73,10 +73,8 @@ jQuery.fn = jQuery.prototype = {
        },
 
        // Execute a callback for every element in the matched set.
-       // (You can seed the arguments with an array of args, but this is
-       // only used internally.)
-       each: function( callback, args ) {
-               return jQuery.each( this, callback, args );
+       each: function( callback ) {
+               return jQuery.each( this, callback );
        },
 
        map: function( callback ) {
@@ -295,40 +293,21 @@ jQuery.extend({
                return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
        },
 
-       // args is for internal usage only
-       each: function( obj, callback, args ) {
+       each: function( obj, callback ) {
                var i = 0,
                        length = obj.length,
                        isArray = isArraylike( obj );
 
-               if ( args ) {
-                       if ( isArray ) {
-                               for ( ; i < length; i++ ) {
-                                       if ( callback.apply( obj[ i ], args ) === false ) {
-                                               break;
-                                       }
-                               }
-                       } else {
-                               for ( i in obj ) {
-                                       if ( callback.apply( obj[ i ], args ) === false ) {
-                                               break;
-                                       }
+               if ( isArray ) {
+                       for ( ; i < length; i++ ) {
+                               if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
+                                       break;
                                }
                        }
-
-               // A special, fast, case for the most common use of each
                } else {
-                       if ( isArray ) {
-                               for ( ; i < length; i++ ) {
-                                       if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
-                                               break;
-                                       }
-                               }
-                       } else {
-                               for ( i in obj ) {
-                                       if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
-                                               break;
-                                       }
+                       for ( i in obj ) {
+                               if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
+                                       break;
                                }
                        }
                }