From d274b7b9f7727e8bccd6906d954e4dc790404d23 Mon Sep 17 00:00:00 2001 From: timmywil Date: Thu, 21 Apr 2011 21:51:23 -0400 Subject: Landing pull request 332. Appending disconnected radio or checkbox inputs and keeping checked setting Fixes #8060, #8500. More Details: - https://github.com/jquery/jquery/pull/332 - http://bugs.jquery.com/ticket/8060 - http://bugs.jquery.com/ticket/8500 --- test/unit/manipulation.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'test/unit') diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index e0fb369a6..b71b6962e 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -227,7 +227,7 @@ test("unwrap()", function() { }); var testAppend = function(valueObj) { - expect(37); + expect(40); var defaultText = "Try them out:" var result = jQuery("#first").append(valueObj("buga")); equals( result.text(), defaultText + "buga", "Check if text appending works" ); @@ -330,6 +330,20 @@ var testAppend = function(valueObj) { d.contents().appendTo("#nonnodes"); d.remove(); ok( jQuery("#nonnodes").contents().length >= 2, "Check node,textnode,comment append cleanup worked" ); + + QUnit.reset(); + var $input = jQuery("").attr({ "type": "checkbox", "checked": true }).appendTo('#testForm'); + equals( $input[0].checked, true, "A checked checkbox that is appended stays checked" ); + + QUnit.reset(); + var $radios = jQuery("input:radio[name='R1']"), + $radioNot = jQuery("").insertAfter( $radios ), + $radio = $radios.eq(1).click(); + $radioNot[0].checked = false; + $radios.parent().wrap("
"); + equals( $radio[0].checked, true, "Reappending radios uphold which radio is checked" ); + equals( $radioNot[0].checked, false, "Reappending radios uphold not being checked" ); + QUnit.reset(); } test("append(String|Element|Array<Element>|jQuery)", function() { -- cgit v1.2.3