Make sure that checked state is cloned properly. Based upon the patch by Michael...
[jquery.git] / test / unit / manipulation.js
index 7db8d5b..b0a1c71 100644 (file)
@@ -197,7 +197,7 @@ test("unwrap()", function() {
 });
 
 var testAppend = function(valueObj) {
-       expect(22);
+       expect(37);
        var defaultText = 'Try them out:'
        var result = jQuery('#first').append(valueObj('<b>buga</b>'));
        equals( result.text(), defaultText + 'buga', 'Check if text appending works' );
@@ -230,6 +230,24 @@ var testAppend = function(valueObj) {
        ok( jQuery("#sap").append(valueObj( [] )), "Check for appending an empty array." );
        ok( jQuery("#sap").append(valueObj( "" )), "Check for appending an empty string." );
        ok( jQuery("#sap").append(valueObj( document.getElementsByTagName("foo") )), "Check for appending an empty nodelist." );
+       
+       reset();
+       jQuery("form").append(valueObj('<input name="radiotest" type="radio" checked="checked" />'));
+       jQuery("form input[name=radiotest]").each(function(){
+               ok( jQuery(this).is(':checked'), "Append checked radio");
+       }).remove();
+
+       reset();
+       jQuery("form").append(valueObj('<input name="radiotest" type="radio" checked    =   \'checked\' />'));
+       jQuery("form input[name=radiotest]").each(function(){
+               ok( jQuery(this).is(':checked'), "Append alternately formated checked radio");
+       }).remove();
+
+       reset();
+       jQuery("form").append(valueObj('<input name="radiotest" type="radio" checked />'));
+       jQuery("form input[name=radiotest]").each(function(){
+               ok( jQuery(this).is(':checked'), "Append HTML5-formated checked radio");
+       }).remove();
 
        reset();
        jQuery("#sap").append(valueObj( document.getElementById('form') ));
@@ -793,7 +811,7 @@ test("clone() on XML nodes", function() {
 }
 
 var testHtml = function(valueObj) {
-       expect(22);
+       expect(24);
 
        jQuery.scriptorder = 0;
 
@@ -805,6 +823,11 @@ var testHtml = function(valueObj) {
        }
        ok( pass, "Set HTML" );
 
+       div = jQuery("<div/>").html( valueObj('<div id="parent_1"><div id="child_1"/></div><div id="parent_2"/>') );
+
+       equals( div.children().length, 2, "Make sure two child nodes exist." );
+       equals( div.children().children().length, 1, "Make sure that a grandchild exists." );
+
        reset();
        // using contents will get comments regular, text, and comment nodes
        var j = jQuery("#nonnodes").contents();
@@ -972,7 +995,7 @@ test("empty()", function() {
 });
 
 test("jQuery.cleanData", function() {
-       expect(10);
+       expect(14);
        
        var type, pos, div, child;
        
@@ -1002,6 +1025,9 @@ test("jQuery.cleanData", function() {
        // Should do nothing
        pos = "Inner";
        child.trigger("click");
+
+       // Should trigger 2
+       div.remove();
        
        type = "html";
        
@@ -1018,6 +1044,9 @@ test("jQuery.cleanData", function() {
        // Should do nothing
        pos = "Inner";
        child.trigger("click");
+
+       // Should trigger 2
+       div.remove();
        
        function getDiv() {
                var div = jQuery("<div class='outer'><div class='inner'></div></div>").click(function(){
@@ -1040,4 +1069,4 @@ test("jQuery.cleanData", function() {
                
                return div;
        }
-});
\ No newline at end of file
+});