Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#11076 closed bug (fixed)

.clone(true) loses delegation filters

Reported by: jquery.com@… Owned by: dmethvin
Priority: high Milestone: 1.7.2
Component: event Version: 1.7.1
Keywords: Cc:
Blocked by: Blocking:


When .delegate is set on a node, and the node or one of its ancestors is cloned with .clone(true), in jQuery 1.7 the delegate's object filter is not conserved and the delegate is transformed in a normal "click" event.

(in both test cases, top table is original and bottom table is cloned one)

1.6.4, correct behavior http://jsfiddle.net/DFv8F/

  • clicking on "head" cell prints "row" in both tables
  • clicking on any "cell" cell prints "cell" in both tables
  • clicking on "last" cell prints "last" in both tables

1.7.1, incorrect behavior http://jsfiddle.net/DFv8F/1/

  • first table (original) behaves as above
  • second table (clone) prints all of "last", "cell" and "row" when clicking on any of the table's cells.

note: adding a second true to .clone has no effect (and no reason to have any, since we're only losing metadata not the events themselves)

Change History (2)

comment:1 Changed 12 years ago by dmethvin

Component: unfiledevent
Milestone: None1.7.2
Owner: set to dmethvin
Priority: undecidedhigh
Status: newassigned

Excellent test case and description, thanks! Yes, cloneCopyEvent() isn't setting the selector properly.

comment:2 Changed 12 years ago by Dave Methvin

Resolution: fixed
Status: assignedclosed

Fix #11076. If .clone() won't delegate, we must remediate.

Since jQuery.event.add can accept a handleObj there's no need to reiterate them as args, but we *do* need to set the selector variable correctly.

Changeset: 633ca9c1610c49dbb780e565f4f1202e1fe20fae

Note: See TracTickets for help on using tickets.