From: David Serduke Date: Wed, 23 Jan 2008 03:54:23 +0000 (+0000) Subject: Fix #2184 by using the jQuery.clean() function instead of a direct innerHTML assignme... X-Git-Tag: 1.2.3a~3 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1faed11e3c0752981d8b01e1272fb3a72272f966;p=jquery.git Fix #2184 by using the jQuery.clean() function instead of a direct innerHTML assignment in the clone() function for IE. --- diff --git a/src/core.js b/src/core.js index b90427b4d..4cb0a22fe 100644 --- a/src/core.js +++ b/src/core.js @@ -303,11 +303,9 @@ jQuery.fn = jQuery.prototype = { // as properties will not be copied (such as the // the name attribute on an input). var clone = this.cloneNode(true), - container = document.createElement("div"), - container2 = document.createElement("div"); + container = document.createElement("div"); container.appendChild(clone); - container2.innerHTML = container.innerHTML; - return container2.firstChild; + return jQuery.clean([container.innerHTML])[0]; } else return this.cloneNode(true); }); diff --git a/test/unit/core.js b/test/unit/core.js index a5a59c3a1..7b0aad4ed 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -955,11 +955,23 @@ test("find(String)", function() { }); test("clone()", function() { - expect(4); + expect(20); ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Assert text for #en' ); var clone = $('#yahoo').clone(); ok( 'Try them out:Yahoo' == $('#first').append(clone).text(), 'Check for clone' ); ok( 'This is a normal link: Yahoo' == $('#en').text(), 'Reassert text for #en' ); + + var cloneTags = [ + "", "", "
", "
", + "