Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#13041 closed bug (wontfix)

Cannot select :focus element

Reported by: [email protected] Owned by:
Priority: low Milestone: 1.9.1
Component: selector Version: 1.8.3
Keywords: Cc: timmywil, gibson042
Blocked by: Blocking:


Updated from 1.8.1 to 1.8.3. Noticed that :focus stopped working.

Working example: http://jsfiddle.net/AvRkY/


<li tabindex="-1">One</li>

$( 'li:first-child' ).focus();
alert( $( 'ul' ).find( 'li:focus' ).size() );

Bug exists in 1.8.2 and above versions: always returns 0.

Change History (6)

comment:1 Changed 10 years ago by dmethvin

Component: unfiledselector
Milestone: None1.9
Priority: undecidedlow
Status: newopen

Here it is working in 1.8.1: http://jsfiddle.net/dmethvin/AvRkY/1/

Most likely affected by the fix for #12648.

It is not a good idea to assume an element is focused synchronously, as this does, because IE fires focus async. It seems to catch the focus immediately in its querySelectorAll implementation because the example above with 1.8.1 works in IE9. However, it does *not* work in IE7.

It looks like you may be trying to roll your own select list, I would warn you away from doing that unless you are aware of ARIA and the issues caused with accessibility.

comment:2 Changed 10 years ago by dmethvin

Cc: timywil gibson042 added

Also I should point out that the :focus selector doesn't seem to work in Firefox on any version of jQuery so this has never been cross-browser. The Selectors Level 3 API seems to leave implementors some leeway:

The :focus pseudo-class applies while an element has the focus (accepts keyboard or mouse events, or other forms of input). ... There may be document language or implementation specific limits on which elements can become :active or acquire :focus.


timmywil or gibson042, if you don't know of a solution I'm inclined to close this wontfix.

comment:3 Changed 10 years ago by dmethvin

Cc: timmywil added; timywil removed

comment:4 Changed 10 years ago by dmethvin


comment:5 Changed 10 years ago by timmywil

Resolution: wontfix
Status: openclosed

The spec leaves it up to the user-agent whether or not elements that are usually not focusable be focused even when the tabIndex is -1. This makes it difficult to provide any consistent behavior. This case is so edgy, I'm closing wontfix.

comment:6 Changed 9 years ago by dmethvin

#14598 is a duplicate of this ticket.

Note: See TracTickets for help on using tickets.