Bug Tracker

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#12041 closed bug (duplicate)

trigger method is trying to access object's properties as functions

Reported by: ido@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:


When using custom events on a JavaScript object (such as window, document or a custom object), if using an event name that equals to a property name on that object, the trigger method will try to run it as a function, throwing an error if it's not a function type.



Will throw: TypeError: Property 'width' of object #<HTMLDocument> is not a function (on WebKit)

The same will happen if I'm using a namespace in my custom events:


If the property is a function the trigger method will call it.


Will cause the page on Chrome to go blank, for example, same as executing:


In my experience it came as a problem when using custom events attached to custom object, as such:

var obj = {a: 1, b: 2, c: 3};
$(obj).on('a.change', function(e) {...});

This will cause an error since the trigger method is going to try and run 'a' as a function.

Tested on all major browsers (Chrome, FF, IE8+, Safari).

Change History (3)

comment:1 Changed 11 years ago by ido@…

jsFiddle example: http://jsfiddle.net/UaJWd/

Notice how the rest of the script will not execute after the first JavaScript error.

comment:2 Changed 11 years ago by dmethvin

Resolution: duplicate
Status: newclosed

comment:3 Changed 11 years ago by dmethvin

Duplicate of #10907.

Note: See TracTickets for help on using tickets.