From 279f77e9609fba62c11a06f8c65221b16f7bc7d4 Mon Sep 17 00:00:00 2001 From: David Serduke Date: Wed, 12 Dec 2007 01:32:35 +0000 Subject: [PATCH] Fixed a bug in clone where it wouldn't work on an XML node in IE. Also added unit test for it. --- src/core.js | 2 +- test/unit/core.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/core.js b/src/core.js index 660f7ee..a37ae78 100644 --- a/src/core.js +++ b/src/core.js @@ -290,7 +290,7 @@ jQuery.fn = jQuery.prototype = { clone: function( events ) { // Do the clone var ret = this.map(function(){ - if ( jQuery.browser.msie ) { + if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) { // IE copies events bound via attachEvent when // using cloneNode. Calling detachEvent on the // clone will also remove the events from the orignal diff --git a/test/unit/core.js b/test/unit/core.js index 3aa66b3..4e77485 100644 --- a/test/unit/core.js +++ b/test/unit/core.js @@ -864,7 +864,7 @@ test("find(String)", function() { }); test("clone()", function() { - expect(4); + expect(6); 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' ); @@ -872,6 +872,16 @@ test("clone()", function() { // using contents will get comments regular, text, and comment nodes var cl = $("#nonnodes").contents().clone(); ok( cl.length >= 2, "Check node,textnode,comment clone works (some browsers delete comments on clone)" ); + + stop(); + $.get("data/dashboard.xml", function (xml) { + var root = $(xml.documentElement).clone(); + $("tab:first", xml).text("origval"); + $("tab:first", root).text("cloneval"); + equals($("tab:first", xml).text(), "origval", "Check original XML node was correctly set"); + equals($("tab:first", root).text(), "cloneval", "Check cloned XML node was correctly set"); + start(); + }); }); test("is(String)", function() { -- 1.7.10.4