From: jeresig Date: Tue, 1 Feb 2011 13:57:18 +0000 (-0500) Subject: The default for .clone() is to not clone any events. Fixes #8123. X-Git-Tag: 1.5.1rc1~73 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=375b78783825b9adab7a01541faf99f98ef7ecbd;p=jquery.git The default for .clone() is to not clone any events. Fixes #8123. --- diff --git a/src/manipulation.js b/src/manipulation.js index 442a14d29..1ef19f83b 100644 --- a/src/manipulation.js +++ b/src/manipulation.js @@ -184,7 +184,7 @@ jQuery.fn.extend({ }, clone: function( dataAndEvents, deepDataAndEvents ) { - dataAndEvents = dataAndEvents == null ? true : dataAndEvents; + dataAndEvents = dataAndEvents == null ? false : dataAndEvents; deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents; return this.map( function () { diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js index f0e2eaec2..e07108696 100644 --- a/test/unit/manipulation.js +++ b/test/unit/manipulation.js @@ -953,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.