Skip to content
Permalink
Browse files

The default for .clone() is to not clone any events. Fixes #8123.

  • Loading branch information...
jeresig committed Feb 1, 2011
1 parent eb5aab9 commit 375b78783825b9adab7a01541faf99f98ef7ecbd
Showing with 12 additions and 1 deletion.
  1. +1 −1 src/manipulation.js
  2. +11 −0 test/unit/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 () {
@@ -953,6 +953,17 @@ test("clone()", function() {
div.remove();
clone.remove();

var divEvt = jQuery("<div><ul><li>test</li></ul></div>").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.

0 comments on commit 375b787

Please sign in to comment.
You can’t perform that action at this time.