#11076 closed bug (fixed)
.clone(true) loses delegation filters
Reported by: | 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/
- 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
Component: | unfiled → event |
---|---|
Milestone: | None → 1.7.2 |
Owner: | set to dmethvin |
Priority: | undecided → high |
Status: | new → assigned |
comment:2 Changed 12 years ago by
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
Excellent test case and description, thanks! Yes,
cloneCopyEvent()
isn't setting the selector properly.