#11076 (.clone(true) loses delegation filters) - jQuery (original) (raw)

#11076 closed bug (fixed)

Opened December 20, 2011 03:11PM UTC

Closed January 28, 2012 09:57PM UTC

Last modified March 08, 2012 11:53PM UTC

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

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/

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

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)

Attachments (0) Change History (2)

Changed December 20, 2011 03:32PM UTC by dmethvin comment:1

component: unfiled → event
milestone: None → 1.7.2
owner: → dmethvin
priority: undecided → high
status: new → assigned

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

Changed January 28, 2012 09:57PM UTC by Dave Methvin comment:2

resolution: → fixed
status: assigned → closed

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