From: rwldrn Date: Tue, 1 Feb 2011 22:54:02 +0000 (-0500) Subject: Fixes #8129. Fix cloning multiple selected options in IE8. X-Git-Tag: 1.5.1rc1~70 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=fa4c90987fc9aede4de3f41976cda91acad81736;p=jquery.git Fixes #8129. Fix cloning multiple selected options in IE8. --- diff --git a/src/manipulation.js b/src/manipulation.js index 1ef19f83b..19a6c22ba 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -503,6 +503,8 @@ jQuery.extend({ // proprietary methods to clear the events. Thanks to MooTools // guys for this hotness. + cloneFixAttributes( elem, clone ); + // Using Sizzle here is crazy slow, so we use getElementsByTagName // instead srcElements = elem.getElementsByTagName("*"); @@ -514,8 +516,6 @@ jQuery.extend({ for ( i = 0; srcElements[i]; ++i ) { cloneFixAttributes( srcElements[i], destElements[i] ); } - - cloneFixAttributes( elem, clone ); } // Copy the events from the original to the clone diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index e07108696..1313783e0 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -1006,7 +1006,7 @@ test("clone()", function() { test("clone(form element) (Bug #3879, #6655)", function() { expect(6); - element = jQuery(""); + var element = jQuery(""); equals( element.clone().find("option:selected").val(), element.find("option:selected").val(), "Selected option cloned correctly" ); @@ -1026,6 +1026,14 @@ test("clone(form element) (Bug #3879, #6655)", function() { equals( clone[0].defaultValue, "foo", "Textarea defaultValue cloned correctly" ); }); +test("clone(multiple selected options) (Bug #8129)", function() { + expect(1); + var element = jQuery(""); + + equals( element.clone().find("option:selected").length, element.find("option:selected").length, "Multiple selected options cloned correctly" ); + +}); + if (!isLocal) { test("clone() on XML nodes", function() { expect(2);