},
before: function() {
- if ( this[0] && this[0].parentNode ) {
+ if ( !isDisconnected( this[0] ) ) {
return this.domManip(arguments, false, function( elem ) {
this.parentNode.insertBefore( elem, this );
});
},
after: function() {
- if ( this[0] && this[0].parentNode ) {
+ if ( !isDisconnected( this[0] ) ) {
return this.domManip(arguments, false, function( elem ) {
this.parentNode.insertBefore( elem, this.nextSibling );
});
},
replaceWith: function( value ) {
- if ( this[0] && this[0].parentNode && this[0].parentNode.nodeType != 11 ) {
+ if ( !isDisconnected( this[0] ) ) {
// Make sure that the elements are removed from the DOM before they are inserted
// this can help fix replacing a parent with child elements
if ( jQuery.isFunction( value ) ) {
equal( res.wrapAll("<div/>").parent().text(), "()", "correctly appended text" );
});
+test("before and after on disconnected node (#10517)", function() {
+ expect(2);
+
+ equal( jQuery("<input type='checkbox'/>").before("<div/>").length, 2, "before() returned all elements" );
+ equal( jQuery("<input type='checkbox'/>").after("<div/>").length, 2, "after() returned all elements" );
+});
+
test("insertBefore(String|Element|Array<Element>|jQuery)", function() {
expect(4);
var expected = "This is a normal link: bugaYahoo";