Bug Tracker

Ticket #8128 (closed bug: duplicate)

Opened 4 years ago

Last modified 4 years ago

IE7 - possible selector error

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

Description

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

comment:1 Changed 4 years ago by jitter

  • Priority changed from undecided to low
  • Resolution set to duplicate
  • Status changed from new to closed
  • Component changed from unfiled to selector

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 4 years ago by jitter

Duplicate of #8105.

comment:3 Changed 4 years ago by scottjehl

Makes sense, sound good. Thanks!

Note: See TracTickets for help on using tickets.