X-Git-Url: http://git.asbjorn.biz/?p=jquery.git;a=blobdiff_plain;f=test%2Funit%2Fmanipulation.js;h=739868bd7bf5d9d4b53e8f8cce78bb713d95dbd1;hp=de841445f66811129c5b83c751b77b81e8c53db0;hb=f1bd0cfc4d3eabf566b6a3345d888e6db67bc00b;hpb=e2941d5a98e91c5f61b200b2763e5fa0eb339365 diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index de84144..739868b 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -402,7 +402,7 @@ test("append(Function) with incoming value", function() { }); test("append the same fragment with events (Bug #6997, 5566)", function () { - expect(4 + (document.fireEvent ? 1 : 0)); + expect(2 + (document.fireEvent ? 1 : 0)); stop(1000); var element; @@ -437,14 +437,6 @@ test("append the same fragment with events (Bug #6997, 5566)", function () { jQuery("#listWithTabIndex li").before(element); jQuery("#listWithTabIndex li.test6997").eq(1).click(); - - element = jQuery(""); - - equals( element.clone().find("option:selected").val(), element.find("option:selected").val(), "Selected option cloned correctly" ); - - element = jQuery("").attr('checked', 'checked'); - - equals( element.clone().is(":checked"), element.is(":checked"), "Checked input cloned correctly" ); }); test("appendTo(String|Element|Array<Element>|jQuery)", function() { @@ -879,6 +871,18 @@ test("replaceAll(String|Element|Array<Element>|jQuery)", function() { ok( !jQuery("#yahoo")[0], 'Verify that original element is gone, after set of elements' ); }); +test("jQuery.clone() (#8017)", function() { + + expect(2); + + ok( jQuery.clone && jQuery.isFunction( jQuery.clone ) , "jQuery.clone() utility exists and is a function."); + + var main = jQuery("#main")[0], + clone = jQuery.clone( main ); + + equals( main.childNodes.length, clone.childNodes.length, "Simple child length to ensure a large dom tree copies correctly" ); +}); + test("clone()", function() { expect(37); equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Assert text for #en' ); @@ -976,6 +980,28 @@ test("clone()", function() { equal( jQuery("body").clone().children()[0].id, "qunit-header", "Make sure cloning body works" ); }); +test("clone(form element) (Bug #3879, #6655)", function() { + expect(6); + element = jQuery(""); + + equals( element.clone().find("option:selected").val(), element.find("option:selected").val(), "Selected option cloned correctly" ); + + element = jQuery("").attr('checked', 'checked'); + clone = element.clone(); + + equals( clone.is(":checked"), element.is(":checked"), "Checked input cloned correctly" ); + equals( clone[0].defaultValue, "foo", "Checked input defaultValue cloned correctly" ); + equals( clone[0].defaultChecked, !jQuery.support.noCloneEvent, "Checked input defaultChecked cloned correctly" ); + + element = jQuery(""); + clone = element.clone(); + equals( clone[0].defaultValue, "foo", "Text input defaultValue cloned correctly" ); + + element = jQuery(""); + clone = element.clone(); + equals( clone[0].defaultValue, "foo", "Textarea defaultValue cloned correctly" ); +}); + if (!isLocal) { test("clone() on XML nodes", function() { expect(2);