jquery fx: sync animations were being left on jQuery.timers (double callback)
[jquery.git] / src / core.js
index 6c439a5..a11ceb4 100644 (file)
@@ -206,20 +206,22 @@ jQuery.fn = jQuery.prototype = {
        },
 
        wrapAll: function( html ) {
-               if ( this[0] )
+               if ( this[0] ) {
                        // The elements to wrap the target around
-                       jQuery( html, this[0].ownerDocument )
-                               .clone()
-                               .insertBefore( this[0] )
-                               .map(function(){
-                                       var elem = this;
-
-                                       while ( elem.firstChild )
-                                               elem = elem.firstChild;
-
-                                       return elem;
-                               })
-                               .append(this);
+                       var wrap = jQuery( html, this[0].ownerDocument ).clone();
+
+                       if ( this[0].parentNode )
+                               wrap.insertBefore( this[0] );
+
+                       wrap.map(function(){
+                               var elem = this;
+
+                               while ( elem.firstChild )
+                                       elem = elem.firstChild;
+
+                               return elem;
+                       }).append(this);
+               }
 
                return this;
        },