Fixed wrapping of elements that hold text nodes. Thanks to David Flanagan for the...
[jquery.git] / src / manipulation.js
index 57b607a..b5ace4d 100644 (file)
@@ -32,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;