From 98df267671ba1d9243d05e74b1ba9cb988c7a1d3 Mon Sep 17 00:00:00 2001 From: Dave Methvin Date: Wed, 25 Jul 2012 14:38:55 -0400 Subject: [PATCH] Revert "Fix #12127. IE9/10 checks fall off the box on clone. Close gh-873." This reverts commit 569d064fc93459695cb6eb6fd09e5ba3fda62f03. Causing test fails in Safari, IE6, and IE7. --- AUTHORS.txt | 1 - src/manipulation.js | 4 +++- src/support.js | 6 +++--- test/unit/manipulation.js | 11 ----------- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/AUTHORS.txt b/AUTHORS.txt index 51200abaf32..774d11b320e 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -129,4 +129,3 @@ David Benjamin Uri Gilad Chris Faulkner Elijah Manor -Daniel Chatfield diff --git a/src/manipulation.js b/src/manipulation.js index fa6083c095b..212eaf6bb22 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -455,7 +455,9 @@ function cloneFixAttributes( src, dest ) { // IE6-8 fails to persist the checked state of a cloned checkbox // or radio button. Worse, IE6-7 fail to give the cloned element // a checked appearance if the defaultChecked value isn't also set - dest.defaultChecked = dest.checked = src.checked; + if ( src.checked ) { + dest.defaultChecked = dest.checked = src.checked; + } // IE6-7 get confused and end up setting the value of a cloned // checkbox/radio button to an empty string instead of "on" diff --git a/src/support.js b/src/support.js index 5bedb4dcbd2..e4a8b7c83cf 100644 --- a/src/support.js +++ b/src/support.js @@ -15,7 +15,7 @@ jQuery.support = (function() { // Preliminary tests div.setAttribute( "className", "t" ); - div.innerHTML = "
a"; + div.innerHTML = "
a"; all = div.getElementsByTagName("*"); a = div.getElementsByTagName("a")[ 0 ]; @@ -96,8 +96,8 @@ jQuery.support = (function() { }; // Make sure checked status is properly cloned - input.checked = false; - support.noCloneChecked = !input.cloneNode( true ).checked; + input.checked = true; + support.noCloneChecked = input.cloneNode( true ).checked; // Make sure that the options inside disabled selects aren't marked as disabled // (WebKit marks them as disabled) diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index e2b00a6626b..31426e73986 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -1895,14 +1895,3 @@ test("html() - script exceptions bubble (#11743)", function() { ok( false, "error ignored" ); }, "exception bubbled from remote script" ); }); - -test("checked state is cloned with clone()", function(){ - expect(2); - - var elem = jQuery.parseHTML('')[0]; - elem.checked = false; - equal( jQuery(elem).clone().attr('id','clone')[0].checked, false, 'Checked false state correctly cloned' ); - elem = jQuery.parseHTML('')[0]; - elem.checked = true; - equal( jQuery(elem).clone().attr('id','clone')[0].checked, true, 'Checked true state correctly cloned' ); -});