Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use while loop instead of for

  • Loading branch information...
commit 668977e03794f5a8ccb8a487796982422ea543ed 1 parent 430bd92
@markelog authored
Showing with 7 additions and 12 deletions.
  1. +7 −12 src/manipulation.js
View
19 src/manipulation.js
@@ -419,16 +419,12 @@ jQuery.extend({
},
buildFragment: function( elems, context, scripts, selection ) {
- var elem, tmp, tag, wrap, j, ll, contains,
- fragment = context.createDocumentFragment(),
+ var elem, tmp, tag, wrap, contains, j,
i = 0,
- l = elems.length,
+ fragment = context.createDocumentFragment(),
nodes = [];
- for ( ; i < l; i++ ) {
- elem = elems[ i ];
-
- if ( elem || elem === 0 ) {
+ while ( ( elem = elems[ i++ ] ) || elem === 0 ) {
// Add nodes directly
if ( jQuery.type( elem ) === "object" ) {
@@ -462,14 +458,13 @@ jQuery.extend({
// Support: Webkit, IE
tmp.textContent = "";
}
- }
}
// Remove wrapper from fragment
fragment.textContent = "";
- for ( i = 0, l = nodes.length; i < l; i++ ) {
- elem = nodes[ i ];
+ i = 0;
+ while ( (elem = nodes[ i++ ]) ) {
contains = jQuery.contains( elem.ownerDocument, elem );
// #4087 - If origin and destination elements are the same, and this is
@@ -488,9 +483,9 @@ jQuery.extend({
// Capture executables
if ( scripts ) {
- for ( j = 0, ll = tmp.length; j < ll; j++ ) {
- elem = tmp[ j ];
+ j = 0;
+ while ( (elem = tmp[ j++ ]) ) {
if ( rscriptType.test( elem.type || "" ) ) {
core_push.call( scripts, elem );
}
Please sign in to comment.
Something went wrong with that request. Please try again.