From 92cd9990971a097b6639607b0d1172e9fe6d0dca Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 9 Feb 2012 15:45:34 +0100 Subject: [PATCH] Fix #11217. WebKit clone() loses check if name follows checked attribute. Please folks, hold your questions. We don't explain em, we just fix em. --- src/support.js | 4 ++++ test/unit/manipulation.js | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/support.js b/src/support.js index 27ef1ab4c..3b64a49be 100644 --- a/src/support.js +++ b/src/support.js @@ -131,6 +131,10 @@ jQuery.support = (function() { support.radioValue = input.value === "t"; input.setAttribute("checked", "checked"); + + // #11217 - WebKit loses check when the name is after the checked attribute + input.setAttribute( "name", "t" ); + div.appendChild( input ); fragment = document.createDocumentFragment(); fragment.appendChild( div.lastChild ); diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 717488178..bfdc1551a 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -265,7 +265,7 @@ test("unwrap()", function() { }); var testAppend = function(valueObj) { - expect(41); + expect(46); var defaultText = "Try them out:" var result = jQuery("#first").append(valueObj("buga")); equal( result.text(), defaultText + "buga", "Check if text appending works" ); @@ -317,6 +317,12 @@ var testAppend = function(valueObj) { ok( jQuery(this).is(":checked"), "Append HTML5-formated checked radio"); }).remove(); + QUnit.reset(); + jQuery("form").append(valueObj("")); + jQuery("form input[name=radiotest]").each(function(){ + ok( jQuery(this).is(":checked"), "Append with name attribute after checked attribute"); + }).remove(); + QUnit.reset(); jQuery("#sap").append(valueObj( document.getElementById("form") )); equal( jQuery("#sap>form").size(), 1, "Check for appending a form" ); // Bug #910