diff --git a/src/manipulation.js b/src/manipulation.js index 2db1cfe3f..5ccd2d9fb 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -285,9 +285,11 @@ jQuery.extend( { cleanData: function( elems ) { var data, elem, type, special = jQuery.event.special, + length = elems.length, i = 0; - for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { + for ( ; i < length; i++ ) { + elem = elems[ i ]; if ( acceptData( elem ) ) { if ( ( data = elem[ dataPriv.expando ] ) ) { if ( data.events ) { diff --git a/src/manipulation/buildFragment.js b/src/manipulation/buildFragment.js index bcb508531..e4bbc3ff3 100644 --- a/src/manipulation/buildFragment.js +++ b/src/manipulation/buildFragment.js @@ -66,7 +66,9 @@ function buildFragment( elems, context, scripts, selection, ignored ) { fragment.textContent = ""; i = 0; - while ( ( elem = nodes[ i++ ] ) ) { + l = nodes.length; + for ( ; i < l; i++ ) { + elem = nodes[ i ]; // Skip elements already in the context collection (trac-4087) if ( selection && jQuery.inArray( elem, selection ) > -1 ) {