Commit e2eac3f4 authored by Dave Methvin's avatar Dave Methvin

Fix #12120. Always stack .before/.after, and fix disconnected nodes.

parent 2263134b
...@@ -148,10 +148,7 @@ jQuery.fn.extend({ ...@@ -148,10 +148,7 @@ jQuery.fn.extend({
}); });
} }
if ( arguments.length ) { return this.pushStack( jQuery.merge( jQuery.clean( arguments ), this ), "before", this.selector );
var set = jQuery.clean( arguments );
return this.pushStack( jQuery.merge( set, this ), "before", this.selector );
}
}, },
after: function() { after: function() {
...@@ -161,10 +158,7 @@ jQuery.fn.extend({ ...@@ -161,10 +158,7 @@ jQuery.fn.extend({
}); });
} }
if ( arguments.length ) { return this.pushStack( jQuery.merge( this.toArray(), jQuery.clean( arguments ) ), "after", this.selector );
var set = jQuery.clean( arguments );
return this.pushStack( jQuery.merge( this, set ), "after", this.selector );
}
}, },
// keepData is for internal use only--do not document // keepData is for internal use only--do not document
...@@ -721,6 +715,7 @@ jQuery.extend({ ...@@ -721,6 +715,7 @@ jQuery.extend({
// Fix #11356: Clear elements from safeFragment // Fix #11356: Clear elements from safeFragment
if ( div ) { if ( div ) {
div.innerHTML = "";
safe.removeChild( div ); safe.removeChild( div );
elem = div = safe = null; elem = div = safe = null;
} }
......
...@@ -909,12 +909,13 @@ test("before(Function)", function() { ...@@ -909,12 +909,13 @@ test("before(Function)", function() {
testBefore(manipulationFunctionReturningObj); testBefore(manipulationFunctionReturningObj);
}); });
test("before and after w/ empty object (#10812)", function() { test("before and after w/ empty object (#10812, #12120)", function() {
expect(2); expect(3);
var res = jQuery( "#notInTheDocument" ).before( "(" ).after( ")" ); var res = jQuery("#notInTheDocument").before("<span>(</span>").after("<span>)</span>");
equal( res.length, 2, "didn't choke on empty object" ); equal( res.length, 2, "added two elements to the empty object" );
equal( res.wrapAll("<div/>").parent().text(), "()", "correctly appended text" ); equal( res.text(), "()", "correctly appended text" );
equal( res.end().text(), "(", "stacked the previous value" );
}); });
test("before and after on disconnected node (#10517)", function() { test("before and after on disconnected node (#10517)", function() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment