Skip to main content

Bug Tracker

Side navigation

#13041 closed bug (wontfix)

Opened December 12, 2012 03:09PM UTC

Closed January 28, 2013 06:01PM UTC

Last modified December 08, 2013 03:22PM UTC

Cannot select :focus element

Reported by: osvaldas.v@gmail.com Owned by:
Priority: low Milestone: 1.9.1
Component: selector Version: 1.8.3
Keywords: Cc: timmywil, gibson042
Blocked by: Blocking:
Description

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

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

..or:

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

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

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

Attachments (0)
Change History (6)

Changed December 12, 2012 04:38PM UTC by dmethvin comment:1

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.

Changed January 26, 2013 10:05PM UTC by dmethvin comment:2

cc: → timywil, gibson042

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.

http://www.w3.org/TR/selectors/#the-user-action-pseudo-classes-hover-act

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

Changed January 26, 2013 10:07PM UTC by dmethvin comment:3

cc: timywil, gibson042timmywil, gibson042

Changed January 28, 2013 03:59PM UTC by dmethvin comment:4

milestone: 1.91.9.1

Changed January 28, 2013 06:01PM UTC by timmywil comment:5

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.

Changed December 08, 2013 03:22PM UTC by dmethvin comment:6

#14598 is a duplicate of this ticket.