Skip to content

Commit

Permalink
Fix jQuery.clean to work with Safari and DOM NodeLists
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonaaron committed Nov 2, 2006
1 parent ddd110c commit 4f92b34
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/jquery/jquery.js
Expand Up @@ -1565,14 +1565,12 @@ 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;

// Have to loop through the childNodes here to
// prevent a Safari crash with text nodes and /n characters
for ( var j = 0; j < div.childNodes.length; j++ )
r.push( div.childNodes[j] );
arg = div.childNodes;
}
else if ( arg.length != undefined && !arg.nodeType ) // Handles Array, jQuery, DOM NodeList collections
for ( var n = 0; n < arg.length; n++ )


if ( arg.length != undefined && ( (jQuery.browser.safari && typeof arg == 'function') || !arg.nodeType ) ) // Safari reports typeof on a DOM NodeList to be a function
for ( var n = 0; n < arg.length; n++ ) // Handles Array, jQuery, DOM NodeList collections
r.push(arg[n]);
else
r.push( arg.nodeType ? arg : document.createTextNode(arg.toString()) );
Expand Down

0 comments on commit 4f92b34

Please sign in to comment.