Skip to main content

Bug Tracker

Side navigation

#7037 closed bug (fixed)

Opened September 15, 2010 04:56PM UTC

Closed September 20, 2011 12:31PM UTC

Duplicate mouseover and mouseout events added to cloned element.

Reported by: patrickwhalen Owned by: dmethvin
Priority: blocker Milestone: 1.7
Component: manipulation Version: 1.4.2
Keywords: clone,events,mouseover,mouseout,1.7-discuss Cc:
Blocked by: Blocking:
Description

When cloning an element that has mouseenter or mouseleave events, the clone will receive a duplicate mouseover and mouseout event causing the handler to double-fire.

So if the jQuery.cache shows this for the original:

mouseenter: Array(1)

mouseover: Array(1)

mouseleave: Array(1)

mouseout: Array(1)

the clone will have:

mouseenter: Array(1)

mouseover: Array(2)

mouseleave: Array(1)

mouseout: Array(2)


Test: http://jsfiddle.net/9y7tp/

The hover for the original element will toggleClass the "blue" class properly and show one alert.

The hover for the clone double-fires the handler, so the toggleClass is called again, and you get 2 alerts.

var $hoverbox = $('.hover').hover(function(e) {

$('#box').toggleClass('blue');

alert(e.type);

});

$hoverbox.clone(true).text("Hover clone").appendTo('body');

Attachments (0)
Change History (19)

Changed October 12, 2010 04:57PM UTC by patrickwhalen comment:1

Just noting that this is still an issue in jQuery 1.4.3 rc1

Changed October 15, 2010 01:11AM UTC by snover comment:2

priority: → high
status: newopen

Changed October 27, 2010 10:09PM UTC by snover comment:3

milestone: 1.4.31.4.5

Retargeting for next release.

Changed January 02, 2011 12:57AM UTC by rwaldron comment:4

owner: → rwaldron
status: openassigned

Changed January 17, 2011 07:00PM UTC by dmethvin comment:5

milestone: 1.4.51.5

Changed March 07, 2011 05:08PM UTC by rwaldron comment:6

#8397 is a duplicate of this ticket.

Changed March 07, 2011 05:10PM UTC by john comment:7

milestone: → 1.next
priority: highblocker

Changed March 07, 2011 05:11PM UTC by john comment:8

milestone: 1.next1.6
owner: rwaldrondmethvin

Changed April 25, 2011 04:07PM UTC by john comment:9

milestone: 1.61.next

Let's bump this and discuss it for 1.7.

Changed May 22, 2011 07:27PM UTC by john comment:10

keywords: clone events mouseover mouseoutclone,events,mouseover,mouseout,1.7-discuss

Nominating ticket for 1.7 discussion.

Changed May 22, 2011 10:04PM UTC by rwaldron comment:11

description: When cloning an element that has mouseenter or mouseleave events, the clone will receive a duplicate mouseover and mouseout event causing the handler to double-fire. \ \ So if the jQuery.cache shows this for the original: \ \ mouseenter: Array(1) \ \ mouseover: Array(1) \ \ mouseleave: Array(1) \ \ mouseout: Array(1) \ \ the clone will have: \ \ mouseenter: Array(1) \ \ mouseover: Array(2) \ \ mouseleave: Array(1) \ \ mouseout: Array(2) \ \ ------- \ \ Test: http://jsfiddle.net/9y7tp/ \ \ \ // The hover for the original element will toggleClass the "blue" class properly and show one alert. \ \ // The hover for the clone double-fires the handler, so the toggleClass is called again, and you get 2 alerts. \ \ var $hoverbox = $('.hover').hover(function(e) { \ $('#box').toggleClass('blue'); \ \ alert(e.type); \ }); \ \ $hoverbox.clone(true).text("Hover clone").appendTo('body'); \ \ When cloning an element that has mouseenter or mouseleave events, the clone will receive a duplicate mouseover and mouseout event causing the handler to double-fire.\ \ So if the jQuery.cache shows this for the original:\ \ mouseenter: Array(1)\ \ mouseover: Array(1)\ \ mouseleave: Array(1)\ \ mouseout: Array(1)\ \ the clone will have:\ \ mouseenter: Array(1)\ \ mouseover: Array(2)\ \ mouseleave: Array(1)\ \ mouseout: Array(2)\ \ -------\ \ Test: http://jsfiddle.net/9y7tp/\ \ \ // The hover for the original element will toggleClass the "blue" class properly and show one alert.\ \ // The hover for the clone double-fires the handler, so the toggleClass is called again, and you get 2 alerts.\ \ var $hoverbox = $('.hover').hover(function(e) {\ $('#box').toggleClass('blue');\ \ alert(e.type);\ });\ \ $hoverbox.clone(true).text("Hover clone").appendTo('body');\ \

+1, Seems like a bug, should be fixed

Changed May 23, 2011 12:11AM UTC by jaubourg comment:12

+1, It's a bug

Changed May 23, 2011 02:01AM UTC by ajpiano comment:13

description: When cloning an element that has mouseenter or mouseleave events, the clone will receive a duplicate mouseover and mouseout event causing the handler to double-fire.\ \ So if the jQuery.cache shows this for the original:\ \ mouseenter: Array(1)\ \ mouseover: Array(1)\ \ mouseleave: Array(1)\ \ mouseout: Array(1)\ \ the clone will have:\ \ mouseenter: Array(1)\ \ mouseover: Array(2)\ \ mouseleave: Array(1)\ \ mouseout: Array(2)\ \ -------\ \ Test: http://jsfiddle.net/9y7tp/\ \ \ // The hover for the original element will toggleClass the "blue" class properly and show one alert.\ \ // The hover for the clone double-fires the handler, so the toggleClass is called again, and you get 2 alerts.\ \ var $hoverbox = $('.hover').hover(function(e) {\ $('#box').toggleClass('blue');\ \ alert(e.type);\ });\ \ $hoverbox.clone(true).text("Hover clone").appendTo('body');\ \ When cloning an element that has mouseenter or mouseleave events, the clone will receive a duplicate mouseover and mouseout event causing the handler to double-fire. \ \ So if the jQuery.cache shows this for the original: \ \ mouseenter: Array(1) \ \ mouseover: Array(1) \ \ mouseleave: Array(1) \ \ mouseout: Array(1) \ \ the clone will have: \ \ mouseenter: Array(1) \ \ mouseover: Array(2) \ \ mouseleave: Array(1) \ \ mouseout: Array(2) \ \ ------- \ \ Test: http://jsfiddle.net/9y7tp/ \ \ \ // The hover for the original element will toggleClass the "blue" class properly and show one alert. \ \ // The hover for the clone double-fires the handler, so the toggleClass is called again, and you get 2 alerts. \ \ var $hoverbox = $('.hover').hover(function(e) { \ $('#box').toggleClass('blue'); \ \ alert(e.type); \ }); \ \ $hoverbox.clone(true).text("Hover clone").appendTo('body'); \ \

+1,

Changed May 23, 2011 03:43AM UTC by timmywil comment:14

description: When cloning an element that has mouseenter or mouseleave events, the clone will receive a duplicate mouseover and mouseout event causing the handler to double-fire. \ \ So if the jQuery.cache shows this for the original: \ \ mouseenter: Array(1) \ \ mouseover: Array(1) \ \ mouseleave: Array(1) \ \ mouseout: Array(1) \ \ the clone will have: \ \ mouseenter: Array(1) \ \ mouseover: Array(2) \ \ mouseleave: Array(1) \ \ mouseout: Array(2) \ \ ------- \ \ Test: http://jsfiddle.net/9y7tp/ \ \ \ // The hover for the original element will toggleClass the "blue" class properly and show one alert. \ \ // The hover for the clone double-fires the handler, so the toggleClass is called again, and you get 2 alerts. \ \ var $hoverbox = $('.hover').hover(function(e) { \ $('#box').toggleClass('blue'); \ \ alert(e.type); \ }); \ \ $hoverbox.clone(true).text("Hover clone").appendTo('body'); \ \ When cloning an element that has mouseenter or mouseleave events, the clone will receive a duplicate mouseover and mouseout event causing the handler to double-fire.\ \ So if the jQuery.cache shows this for the original:\ \ mouseenter: Array(1)\ \ mouseover: Array(1)\ \ mouseleave: Array(1)\ \ mouseout: Array(1)\ \ the clone will have:\ \ mouseenter: Array(1)\ \ mouseover: Array(2)\ \ mouseleave: Array(1)\ \ mouseout: Array(2)\ \ -------\ \ Test: http://jsfiddle.net/9y7tp/\ \ \ // The hover for the original element will toggleClass the "blue" class properly and show one alert.\ \ // The hover for the clone double-fires the handler, so the toggleClass is called again, and you get 2 alerts.\ \ var $hoverbox = $('.hover').hover(function(e) {\ $('#box').toggleClass('blue');\ \ alert(e.type);\ });\ \ $hoverbox.clone(true).text("Hover clone").appendTo('body');\ \

+1,

Changed June 03, 2011 01:38PM UTC by john comment:15

+1, Oof, let's get this fixed.

Changed June 03, 2011 03:11PM UTC by scottgonzalez comment:16

+1

Changed June 06, 2011 03:54PM UTC by jzaefferer comment:17

+0

Changed July 12, 2011 02:45PM UTC by dmethvin comment:18

description: When cloning an element that has mouseenter or mouseleave events, the clone will receive a duplicate mouseover and mouseout event causing the handler to double-fire.\ \ So if the jQuery.cache shows this for the original:\ \ mouseenter: Array(1)\ \ mouseover: Array(1)\ \ mouseleave: Array(1)\ \ mouseout: Array(1)\ \ the clone will have:\ \ mouseenter: Array(1)\ \ mouseover: Array(2)\ \ mouseleave: Array(1)\ \ mouseout: Array(2)\ \ -------\ \ Test: http://jsfiddle.net/9y7tp/\ \ \ // The hover for the original element will toggleClass the "blue" class properly and show one alert.\ \ // The hover for the clone double-fires the handler, so the toggleClass is called again, and you get 2 alerts.\ \ var $hoverbox = $('.hover').hover(function(e) {\ $('#box').toggleClass('blue');\ \ alert(e.type);\ });\ \ $hoverbox.clone(true).text("Hover clone").appendTo('body');\ \ When cloning an element that has mouseenter or mouseleave events, the clone will receive a duplicate mouseover and mouseout event causing the handler to double-fire. \ \ So if the jQuery.cache shows this for the original: \ \ mouseenter: Array(1) \ \ mouseover: Array(1) \ \ mouseleave: Array(1) \ \ mouseout: Array(1) \ \ the clone will have: \ \ mouseenter: Array(1) \ \ mouseover: Array(2) \ \ mouseleave: Array(1) \ \ mouseout: Array(2) \ \ ------- \ \ Test: http://jsfiddle.net/9y7tp/ \ \ \ // The hover for the original element will toggleClass the "blue" class properly and show one alert. \ \ // The hover for the clone double-fires the handler, so the toggleClass is called again, and you get 2 alerts. \ \ var $hoverbox = $('.hover').hover(function(e) { \ $('#box').toggleClass('blue'); \ \ alert(e.type); \ }); \ \ $hoverbox.clone(true).text("Hover clone").appendTo('body'); \ \
milestone: 1.next1.7

Changed September 20, 2011 12:31PM UTC by dmethvin comment:19

resolution: → fixed
status: assignedclosed