From ca6993fc780794add562a470c5089da1577dc4db Mon Sep 17 00:00:00 2001 From: Noah Sloan Date: Fri, 29 Jan 2010 11:41:41 -0600 Subject: [PATCH] Fix for Ticket #5986 - replaceWith mishandles strings --- src/manipulation.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/manipulation.js b/src/manipulation.js index 88da6de527..2a1a093481 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -266,8 +266,11 @@ jQuery.fn.extend({ // Make sure that the elements are removed from the DOM before they are inserted // this can help fix replacing a parent with child elements if ( !jQuery.isFunction( value ) ) { - value = jQuery( value ).detach(); - + // API says a string is an HTML string, so evaling and + // detaching will only cause problems + if(typeof value !== 'string') { + value = jQuery(value).detach(); + } } else { return this.each(function(i) { var self = jQuery(this), old = self.html();