Skip to main content

Bug Tracker

Side navigation

#7651 closed bug (duplicate)

Opened November 29, 2010 05:47PM UTC

Closed December 18, 2010 09:14PM UTC

Last modified December 18, 2010 09:14PM UTC

bind() and trigger() fail on plain javascript objects if a method “handle” exists

Reported by: rs@mini-cms.ch Owned by:
Priority: blocker Milestone: 1.5
Component: event Version: 1.4.4
Keywords: regression Cc:
Blocked by: Blocking:
Description

This is a regression from the changes made in 1.4.3. The following works fine:

var a = {};
jQuery(a).bind("myEvent", function() {
    jQuery('body').text("Gaga");
});
jQuery(a).trigger('myEvent');

Whereas this does not work:

var a = {};
a.handle = function(){};
jQuery(a).bind("myEvent", function() {
    jQuery('body').text("Gaga");
});
jQuery(a).trigger('myEvent');
Attachments (0)
Change History (7)

Changed November 29, 2010 05:48PM UTC by anonymous comment:1

Both variants work fine in jQuery 1.4.2.

Test case is at http://www.jsfiddle.net/ZtKLD/

Changed November 29, 2010 09:53PM UTC by snover comment:2

keywords: → regression
milestone: 1.next1.5
priority: undecidedblocker
status: newopen

Changed November 29, 2010 09:53PM UTC by snover comment:3

component: unfiledevent

Changed November 30, 2010 01:49AM UTC by rwaldron comment:4

Could this possibly be related to #7500 ?

Changed November 30, 2010 04:27PM UTC by jitter comment:5

Replying to [comment:4 rwaldron]:

Could this possibly be related to #7500 ?

I don't think so. This probably comes from the changes in 1.4.3 to the data() method, as we now are storing the data() data on plain js objects directly.

Now the events add() method seem to get confused here and here as elemData.handle is now set when there is a "handle" property on the js object. Which of course it wasn't in 1.4.2 where data() returned nothing on a plain js object unless there was already data associated with it in the internal cache. But in 1.4.2 a similar bug existed the other way around

http://jsfiddle.net/jitter/zPz7j/

So the main issue is we really shouldn't be storing a property named handle directly on a js object.

Changed December 18, 2010 09:14PM UTC by rwaldron comment:6

resolution: → duplicate
status: openclosed

Changed December 18, 2010 09:14PM UTC by rwaldron comment:7

Duplicate of #6968.