From: Jordan Boesch Date: Sat, 5 Mar 2011 15:30:29 +0000 (-0600) Subject: bug 6158; fixing replaceWith from throwing errors on empty elements X-Git-Url: http://git.asbjorn.biz/?a=commitdiff_plain;ds=sidebyside;h=5c2d70979c15bbda5c90e1634abe11d8c350abcb;p=jquery.git bug 6158; fixing replaceWith from throwing errors on empty elements --- diff --git a/src/manipulation.js b/src/manipulation.js index ba31697..a4a81de 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -261,6 +261,9 @@ jQuery.fn.extend({ } }); } else { + if ( !this.length ) { + return this; + } return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ); } },