Skip to content

Commit a5be986

Browse files
committed
Revert "Fix #12120. Always stack .before/.after, and fix disconnected nodes."
This reverts commit e2eac3f. There is a 1.7 regression with isDisconnected() that we should fix before tackling this.
1 parent e2eac3f commit a5be986

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/manipulation.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,10 @@ jQuery.fn.extend({
148148
});
149149
}
150150

151-
return this.pushStack( jQuery.merge( jQuery.clean( arguments ), this ), "before", this.selector );
151+
if ( arguments.length ) {
152+
var set = jQuery.clean( arguments );
153+
return this.pushStack( jQuery.merge( set, this ), "before", this.selector );
154+
}
152155
},
153156

154157
after: function() {
@@ -158,7 +161,10 @@ jQuery.fn.extend({
158161
});
159162
}
160163

161-
return this.pushStack( jQuery.merge( this.toArray(), jQuery.clean( arguments ) ), "after", this.selector );
164+
if ( arguments.length ) {
165+
var set = jQuery.clean( arguments );
166+
return this.pushStack( jQuery.merge( this, set ), "after", this.selector );
167+
}
162168
},
163169

164170
// keepData is for internal use only--do not document
@@ -715,7 +721,6 @@ jQuery.extend({
715721

716722
// Fix #11356: Clear elements from safeFragment
717723
if ( div ) {
718-
div.innerHTML = "";
719724
safe.removeChild( div );
720725
elem = div = safe = null;
721726
}

test/unit/manipulation.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -909,13 +909,12 @@ test("before(Function)", function() {
909909
testBefore(manipulationFunctionReturningObj);
910910
});
911911

912-
test("before and after w/ empty object (#10812, #12120)", function() {
913-
expect(3);
912+
test("before and after w/ empty object (#10812)", function() {
913+
expect(2);
914914

915-
var res = jQuery("#notInTheDocument").before("<span>(</span>").after("<span>)</span>");
916-
equal( res.length, 2, "added two elements to the empty object" );
917-
equal( res.text(), "()", "correctly appended text" );
918-
equal( res.end().text(), "(", "stacked the previous value" );
915+
var res = jQuery( "#notInTheDocument" ).before( "(" ).after( ")" );
916+
equal( res.length, 2, "didn't choke on empty object" );
917+
equal( res.wrapAll("<div/>").parent().text(), "()", "correctly appended text" );
919918
});
920919

921920
test("before and after on disconnected node (#10517)", function() {

0 commit comments

Comments
 (0)