]> source.dussan.org Git - jquery.git/commitdiff
Loop cleanup
authorRick Waldron <waldron.rick@gmail.com>
Wed, 17 Apr 2013 02:37:48 +0000 (22:37 -0400)
committerRick Waldron <waldron.rick@gmail.com>
Wed, 17 Apr 2013 02:37:48 +0000 (22:37 -0400)
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
src/manipulation.js

index ac1bf2bbf977766044569de857ddfc0459a37125..640dfcd6f40a4f761b81e0c98007c1b3b650062d 100644 (file)
@@ -75,12 +75,9 @@ jQuery.fn.extend({
        remove: function( selector, keepData ) {
                var elem,
                        elems = selector ? jQuery.filter( selector, this ) : this,
-                       i = 0,
-                       l = elems.length;
-
-               for ( ; i < l; i++ ) {
-                       elem = elems[ i ];
+                       i = 0;
 
+               for ( ; (elem = elems[i]) != null; i++ ) {
                        if ( !keepData && elem.nodeType === 1 ) {
                                jQuery.cleanData( getAll( elem ) );
                        }
@@ -98,12 +95,9 @@ jQuery.fn.extend({
 
        empty: function() {
                var elem,
-                       i = 0,
-                       l = this.length;
-
-               for ( ; i < l; i++ ) {
-                       elem = this[ i ];
+                       i = 0;
 
+               for ( ; (elem = this[i]) != null; i++ ) {
                        if ( elem.nodeType === 1 ) {
 
                                // Prevent memory leaks