Bug Tracker

Opened 10 years ago

Closed 10 years ago

#12492 closed bug (fixed)

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

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


jsFiddle here: http://jsfiddle.net/hJwKC/4/

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).

Change History (6)

comment:1 Changed 10 years ago by dmethvin

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. http://jsfiddle.net/hJwKC/7/

comment:2 Changed 10 years ago by mikesherov

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: http://api.jquery.com/focus-selector/

comment:3 Changed 10 years ago by mikesherov

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".

comment:4 Changed 10 years ago by mikesherov

Owner: set to mikesherov
Status: reopenedassigned

comment:6 Changed 10 years ago by Timmy Willison

Resolution: fixed
Status: assignedclosed

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

Changeset: 01d406522095a26788b1975852ad7c1ee7cf6e34

Note: See TracTickets for help on using tickets.