mirror of
https://github.com/jquery/jquery.git
synced 2026-04-20 03:01:22 -04:00
Only try to wrap the element if it's not disconnected, fixed #3828.
This commit is contained in:
24
src/core.js
24
src/core.js
@@ -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;
|
||||
var wrap = jQuery( html, this[0].ownerDocument ).clone();
|
||||
|
||||
while ( elem.firstChild )
|
||||
elem = elem.firstChild;
|
||||
if ( this[0].parentNode )
|
||||
wrap.insertBefore( this[0] );
|
||||
|
||||
return elem;
|
||||
})
|
||||
.append(this);
|
||||
wrap.map(function(){
|
||||
var elem = this;
|
||||
|
||||
while ( elem.firstChild )
|
||||
elem = elem.firstChild;
|
||||
|
||||
return elem;
|
||||
}).append(this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user