Skip to main content

Bug Tracker

Side navigation

#13627 closed bug (wontfix)

Opened March 19, 2013 06:22PM UTC

Closed March 19, 2013 06:57PM UTC

Focus event bound on a plain JS object does not work correctly.

Reported by: Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

We use jQuery to bind/trigger events on plain JS objects like so. One of our objects has a method on it called "focus", and we also define a method on it called "focus", like so:

var obj = { focus: function() {} };
jQuery(obj).bind('focus', fn);

// later on

In jQuery 1.8.3, both the focus member and the focus event would get invoked. In jQuery 1.9.1, only the focus member gets invoked. This is definitely an edge case, but it represents a diffence of behaviour between jQuery 1.8.3 and jQuery 1.9.1. The reason comes down to a special event defined for IE's sake that tries to call the focus method of the DOM element. Ideally (for me anyways), the special event would make sure the object is a DOM node before invoking thereby creating a distinction between events and methods, but I understand that it may not be practical to actually implement that way for such an edge use case. Just want to log this change in behaviour somewhere in case this trips up any other people.


Attachments (0)
Change History (3)

Changed March 19, 2013 06:36PM UTC by dmethvin comment:1

owner: →
status: newpending

In general you should not use DOM event names if you don't want DOM semantics. Otherwise we'd need to check for special cases all over the place. Is there a problem doing that in your app?

Changed March 19, 2013 06:53PM UTC by comment:2

status: pendingnew

Well we've created a UI widget toolkit and used jQuery for the eventing system (among other things), so event names such as "focus", "blur", etc. are perfectly valid names for events on non-DOM objects in my case.

I guess my real concern is that notes like the one @dmethvin put in this issue are not easily found (or are they? I honestly have not read the docs in a while, but there doesn't seem to be a mention of anything similar in the trigger docs..)

Again, I don't necessarily expect a fix, and don't ''really'' consider this a bug either TBH. My use case is rather on the edge, but it is something that tripped me up in the migration to 1.9.1.

Changed March 19, 2013 06:57PM UTC by dmethvin comment:3

resolution: → wontfix
status: newclosed

Triggering events on plain objects isn't a common thing. There's an open api docs ticket and I've just added a ref to here.