From 375b78783825b9adab7a01541faf99f98ef7ecbd Mon Sep 17 00:00:00 2001 From: jeresig Date: Tue, 1 Feb 2011 08:57:18 -0500 Subject: [PATCH] The default for .clone() is to not clone any events. Fixes #8123. --- src/manipulation.js | 2 +- test/unit/manipulation.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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. -- 2.39.5