X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=test%2Funit%2Fmanipulation.js;h=1313783e0be4e2da4da6c02ab43608cc4944de4f;hb=8f8961de90453274ac194479272a8dfa99ffab17;hp=37234d86d3e2443496239573080d92d1ac1e3668;hpb=e78d3a7e2d47e9796f87c18b76f8178b0bee42c5;p=jquery.git diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index 37234d8..1313783 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -871,6 +871,31 @@ 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() (#8070)", function () { + expect(2); + + jQuery('').appendTo('#main'); + var selects = jQuery('.test8070'); + selects.append(''); + + equals( selects[0].childNodes.length, 2, "First select got two nodes" ); + equals( selects[1].childNodes.length, 2, "Second select got two nodes" ); + + selects.remove(); +}); + test("clone()", function() { expect(37); equals( 'This is a normal link: Yahoo', jQuery('#en').text(), 'Assert text for #en' ); @@ -928,6 +953,17 @@ test("clone()", function() { div.remove(); clone.remove(); + var divEvt = jQuery("
").click(function(){ + ok( false, "Bound event still exists after .clone()." ); + }), + cloneEvt = divEvt.clone(); + + // Make sure that doing .clone() doesn't clone events + cloneEvt.trigger("click"); + + cloneEvt.remove(); + divEvt.remove(); + // this is technically an invalid object, but because of the special // classid instantiation it is the only kind that IE has trouble with, // so let's test with it too. @@ -970,7 +1006,7 @@ test("clone()", function() { test("clone(form element) (Bug #3879, #6655)", function() { expect(6); - element = jQuery(""); + var element = jQuery(""); equals( element.clone().find("option:selected").val(), element.find("option:selected").val(), "Selected option cloned correctly" ); @@ -990,6 +1026,14 @@ test("clone(form element) (Bug #3879, #6655)", function() { equals( clone[0].defaultValue, "foo", "Textarea defaultValue cloned correctly" ); }); +test("clone(multiple selected options) (Bug #8129)", function() { + expect(1); + var element = jQuery(""); + + equals( element.clone().find("option:selected").length, element.find("option:selected").length, "Multiple selected options cloned correctly" ); + +}); + if (!isLocal) { test("clone() on XML nodes", function() { expect(2);