Skip to main content

Bug Tracker

Side navigation

#12041 closed bug (duplicate)

Opened July 08, 2012 08:21AM UTC

Closed July 12, 2012 01:42AM UTC

Last modified July 12, 2012 01:42AM UTC

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

Reported by: 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).

Attachments (0)
Change History (3)

Changed July 08, 2012 08:26AM UTC by comment:1

jsFiddle example:

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

Changed July 12, 2012 01:42AM UTC by dmethvin comment:2

resolution: → duplicate
status: newclosed

Changed July 12, 2012 01:42AM UTC by dmethvin comment:3

Duplicate of #10907.