bug 6158; fixing replaceWith from throwing errors on non existant elements
[jquery.git] / src / manipulation.js
index a4a81de..613faab 100644 (file)
@@ -261,10 +261,9 @@ jQuery.fn.extend({
                                }
                        });
                } else {
-            if ( !this.length ) {
-                return this;
-            }
-                       return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
+                       return ( this.length ) ?
+                               this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ) :
+                               this;
                }
        },