From 5c2d70979c15bbda5c90e1634abe11d8c350abcb Mon Sep 17 00:00:00 2001 From: Jordan Boesch Date: Sat, 5 Mar 2011 09:30:29 -0600 Subject: [PATCH] bug 6158; fixing replaceWith from throwing errors on empty elements --- src/manipulation.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/manipulation.js b/src/manipulation.js index ba3169715..a4a81de44 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 ); } }, -- 2.39.5