Bug Tracker

Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#8128 closed bug (duplicate)

IE7 - possible selector error

Reported by: scottjehl Owned by:
Priority: low Milestone: 1.next
Component: selector Version: 1.5
Keywords: Cc:
Blocked by: Blocking:


I'm not sure if this is a bug or not, but in jQuery Mobile we use the following selector to find any focused element on the page and blur it (which in turn hides the keyboard):

$( window.document.activeElement ).add(':focus').blur();

The :focus selector throws an exception in both IE7 and Windows Mobile. Changing it to something more specific, like "input:focus, textarea:focus" avoids the problem, but I figured I should post this in case it's actually a bug.

Change History (3)

comment:1 Changed 12 years ago by jitter

Component: unfiledselector
Priority: undecidedlow
Resolution: duplicate
Status: newclosed

Hey Scott, this isn't a bug. :focus isn't a selector jQuery core supports officially.

It's a valid CSS3 selector and thus $(":focus") (and the like) happen to "just work" in all browsers which support querySelectorAll. But this selector will fail in any browser which does not have qSA (as this test case shows by disabling qSA).

So you probably should check if qSA is available before doing .add(":focus").

Anyway, maybe it's just a coincidence but Paul Irish recently proposed adding :focus as supported selector. So please follow the ticket mentioned below for progress on this issue.

comment:2 Changed 12 years ago by jitter

Duplicate of #8105.

comment:3 Changed 12 years ago by scottjehl

Makes sense, sound good. Thanks!

Note: See TracTickets for help on using tickets.