// this can help fix replacing a parent with child elements
if ( !jQuery.isFunction( value ) ) {
value = jQuery( value ).detach();
+
+ } else {
+ return this.each(function(i) {
+ var self = jQuery(this), old = self.html();
+ self.replaceWith( value.call( this, i, old ) );
+ });
}
return this.each(function() {
test("replaceWith(Function)", function() {
testReplaceWith(functionReturningObj);
+
+ expect(16);
+
+ var y = jQuery("#yahoo")[0];
+
+ jQuery(y).replaceWith(function(){
+ equals( this, y, "Make sure the context is coming in correctly." );
+ });
+
+ reset();
})
test("replaceAll(String|Element|Array<Element>|jQuery)", function() {