X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=src%2Fmanipulation.js;h=55017c196ff82a15ec3cd6c6a9143c0427c80b24;hb=190812c3be99bde536d373b6b6ab65cfe053a532;hp=59973deee8ba546bd1612eab9a471f38b61da690;hpb=7d7a960035b7431887581c9cef09eaaef28e3d27;p=jquery.git diff --git a/src/manipulation.js b/src/manipulation.js index 59973de..55017c1 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -18,9 +18,13 @@ jQuery.fn.extend({ }, wrapAll: function( html ) { + if(jQuery.isFunction(html)) { + return this.each(function() { jQuery(this).wrapAll(html.call(this)); }); + } + if ( this[0] ) { // The elements to wrap the target around - var wrap = jQuery( html, this[0].ownerDocument ).clone(); + var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(); if ( this[0].parentNode ) wrap.insertBefore( this[0] ); @@ -28,7 +32,7 @@ jQuery.fn.extend({ wrap.map(function(){ var elem = this; - while ( elem.firstChild ) + while ( elem.firstChild && elem.firstChild.nodeType === 1 ) elem = elem.firstChild; return elem;