});
}
- if ( arguments.length ) {
- var set = jQuery.clean( arguments );
- return this.pushStack( jQuery.merge( set, this ), "before", this.selector );
- }
+ return this.pushStack( jQuery.merge( jQuery.clean( arguments ), this ), "before", this.selector );
},
after: function() {
});
}
- if ( arguments.length ) {
- var set = jQuery.clean( arguments );
- return this.pushStack( jQuery.merge( this, set ), "after", this.selector );
- }
+ return this.pushStack( jQuery.merge( this.toArray(), jQuery.clean( arguments ) ), "after", this.selector );
},
// keepData is for internal use only--do not document
// Fix #11356: Clear elements from safeFragment
if ( div ) {
+ div.innerHTML = "";
safe.removeChild( div );
elem = div = safe = null;
}
testBefore(manipulationFunctionReturningObj);
});
-test("before and after w/ empty object (#10812)", function() {
- expect(2);
+test("before and after w/ empty object (#10812, #12120)", function() {
+ expect(3);
- var res = jQuery( "#notInTheDocument" ).before( "(" ).after( ")" );
- equal( res.length, 2, "didn't choke on empty object" );
- equal( res.wrapAll("<div/>").parent().text(), "()", "correctly appended text" );
+ var res = jQuery("#notInTheDocument").before("<span>(</span>").after("<span>)</span>");
+ equal( res.length, 2, "added two elements to the empty object" );
+ equal( res.text(), "()", "correctly appended text" );
+ equal( res.end().text(), "(", "stacked the previous value" );
});
test("before and after on disconnected node (#10517)", function() {