Skip to main content

Bug Tracker

Side navigation

#12492 closed bug (fixed)

Opened September 09, 2012 01:52PM UTC

Closed September 11, 2012 06:50PM UTC

In textarea focus event handler, $(this).is(':focus') == false in Chrome & Safari

Reported by: Owned by: mikesherov
Priority: low Milestone: 1.8.2
Component: selector Version: 1.8.0
Keywords: Cc:
Blocked by: Blocking:

jsFiddle here:

All browsers report 'true,true', except Chrome and Safari which both report 'false,true'. The same is the case for <input> tags.

I'm not sure what the expected behaviour is - whether an element should only report as focused after the focus handler has completed, but the cross browser inconsistency led me to believe it could be a bug. I realise it could also be a webkit bug (or feature).

Attachments (0)
Change History (6)

Changed September 09, 2012 02:10PM UTC by dmethvin comment:1

resolution: → wontfix
status: newclosed

Seems like a Webkit bug to me. One workaround is to use document.activeElement, which is also a lot more efficient than using .is() with a selector. For that reason I'll close this wontfix, you could file a bug with them if you want to use the selector anyway.

Changed September 09, 2012 02:52PM UTC by mikesherov comment:2

Just to follow up even further, the API page on :focus seems to be aware of the bug and uses a setTimeout to achieve consistency:

Changed September 09, 2012 04:25PM UTC by mikesherov comment:3

component: unfiledselector
milestone: None1.8.2
priority: undecidedlow
resolution: wontfix
status: closedreopened

Actually, this is really easy to fix. We can just declare chrome's matchesSelector buggy for ":focus".

Changed September 09, 2012 04:25PM UTC by mikesherov comment:4

owner: → mikesherov
status: reopenedassigned

Changed September 09, 2012 05:13PM UTC by mikesherov comment:5

Changed September 11, 2012 06:50PM UTC by Timmy Willison comment:6

resolution: → fixed
status: assignedclosed

Sizzle: fix selector in Chrome 21. Fixes #12492.

Changeset: 01d406522095a26788b1975852ad7c1ee7cf6e34