From 4bcb578c794acd913ec1f42793ce4b1a7388025c Mon Sep 17 00:00:00 2001 From: Brandon Aaron Date: Thu, 19 Oct 2006 21:47:05 +0000 Subject: [PATCH 1/1] More clean up on jQuery.clean --- src/jquery/jquery.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 303350a..3816296 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -1548,9 +1548,10 @@ jQuery.extend({ clean: function(a) { var r = []; for ( var i = 0; i < a.length; i++ ) { - if ( a[i].constructor == String ) { // Convert html string into DOM nodes + var arg = a[i]; + if ( arg.constructor == String ) { // Convert html string into DOM nodes // Trim whitespace, otherwise indexOf won't work as expected - var s = jQuery.trim(a[i]), div = document.createElement("div"), wrap = [0,"",""]; + var s = jQuery.trim(arg), div = document.createElement("div"), wrap = [0,"",""]; if ( !s.indexOf("", ""]; @@ -1564,14 +1565,14 @@ jQuery.extend({ // Go to html and back, then peel off extra wrappers div.innerHTML = wrap[1] + s + wrap[2]; while ( wrap[0]-- ) div = div.firstChild; - a[i] = div.childNodes; + arg = div.childNodes; } - if ( a[i].length != undefined && !a[i].nodeType ) // Handles Array, jQuery, DOM NodeList collections - for ( var n=0; n < a[i].length; n++ ) - r.push(a[i][n]); - else if ( a[i] !== null ) - r.push( a[i].nodeType ? a[i] : document.createTextNode(a[i].toString()) ); + if ( arg.length != undefined && !arg.nodeType ) // Handles Array, jQuery, DOM NodeList collections + for ( var n = 0; n < arg.length; n++ ) + r.push(arg[n]); + else + r.push( arg.nodeType ? arg : document.createTextNode(arg.toString()) ); } return r; -- 1.7.10.4