Bug Tracker

Ticket #7037 (closed bug: fixed)

Opened 4 years ago

Last modified 3 years ago

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:
Blocking: Blocked by:

Description (last modified by dmethvin) (diff)

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');

Change History

comment:1 Changed 4 years ago by patrickwhalen

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

comment:2 Changed 4 years ago by snover

  • Priority set to high
  • Status changed from new to open

comment:3 Changed 4 years ago by snover

  • Milestone changed from 1.4.3 to 1.4.5

Retargeting for next release.

comment:4 Changed 4 years ago by rwaldron

  • Owner set to rwaldron
  • Status changed from open to assigned

comment:5 Changed 4 years ago by dmethvin

  • Milestone changed from 1.4.5 to 1.5

comment:6 Changed 4 years ago by rwaldron

#8397 is a duplicate of this ticket.

comment:7 Changed 4 years ago by john

  • Priority changed from high to blocker
  • Milestone set to 1.next

comment:8 Changed 4 years ago by john

  • Owner changed from rwaldron to dmethvin
  • Milestone changed from 1.next to 1.6

comment:9 Changed 4 years ago by john

  • Milestone changed from 1.6 to 1.next

Let's bump this and discuss it for 1.7.

comment:10 Changed 4 years ago by john

  • Keywords clone,events,mouseover,mouseout,1.7-discuss added; clone events mouseover mouseout removed

Nominating ticket for 1.7 discussion.

comment:11 Changed 4 years ago by rwaldron

  • Description modified (diff)

+1, Seems like a bug, should be fixed

comment:12 Changed 4 years ago by jaubourg

+1, It's a bug

comment:13 Changed 4 years ago by ajpiano

  • Description modified (diff)

+1,

comment:14 Changed 4 years ago by timmywil

  • Description modified (diff)

+1,

comment:15 Changed 3 years ago by john

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

comment:16 Changed 3 years ago by scott.gonzalez

+1

comment:17 Changed 3 years ago by jzaefferer

+0

comment:18 Changed 3 years ago by dmethvin

  • Description modified (diff)
  • Milestone changed from 1.next to 1.7

comment:19 Changed 3 years ago by dmethvin

  • Status changed from assigned to closed
  • Resolution set to fixed
Note: See TracTickets for help on using tickets.