Skip to content
Permalink
Browse files

Fixes #8129. Fix cloning multiple selected options in IE8.

  • Loading branch information...
rwaldron authored and jitter committed Feb 1, 2011
1 parent cb85da7 commit fa4c90987fc9aede4de3f41976cda91acad81736
Showing with 11 additions and 3 deletions.
  1. +2 −2 src/manipulation.js
  2. +9 −1 test/unit/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
@@ -1006,7 +1006,7 @@ test("clone()", function() {

test("clone(form element) (Bug #3879, #6655)", function() {
expect(6);
element = jQuery("<select><option>Foo</option><option selected>Bar</option></select>");
var element = jQuery("<select><option>Foo</option><option selected>Bar</option></select>");

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("<select><option>Foo</option><option selected>Bar</option><option selected>Baz</option></select>");

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);

0 comments on commit fa4c909

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.