Skip to main content

Bug Tracker

Side navigation

#4774 closed bug (worksforme)

Opened June 17, 2009 08:55AM UTC

Closed December 29, 2009 07:56PM UTC

Last modified February 21, 2011 05:43PM UTC

Unknown pseudo-class or pseudo-element 'selected'

Reported by: Dan86 Owned by: john
Priority: minor Milestone: 1.4
Component: selector Version: 1.3.2
Keywords: selected pseudo-element Cc:
Blocked by: Blocking:
Description

Every time a selector try to select the selected items in <select>, it throws a "Warning: Unknown pseudo-class or pseudo-element 'selected'." warning in the error console in Firefox.

If you go to this page you can check it out, the warning is shown in there too:

http://docs.jquery.com/Selectors/selected

(using Firefox 3.5 Release Candidate)

Attachments (1)
  • test-4774.html (0.5 KB) - added by dmethvin December 29, 2009 07:32PM UTC.

    Repro for #4774 on FF 3.5.

Change History (7)

Changed October 03, 2009 01:09AM UTC by dmethvin comment:1

resolution: → invalid
status: newclosed

Please reopen with a test case if this is still a problem with FF 3.5 final.

Changed October 09, 2009 07:00PM UTC by geckoneer comment:2

resolution: invalid
status: closedreopened

Yes, it is still a problem in FF 3.5 final.

Changed October 09, 2009 09:29PM UTC by dmethvin comment:3

Using Firefox 3.5.3 on Windows XP I am not seeing any console error messages on this page, regardless of what I do:

http://docs.jquery.com/Selectors/selected

If you can provide a test case I can leave the ticket open.

Changed December 05, 2009 05:13AM UTC by john comment:4

resolution: → invalid
status: reopenedclosed

Changed December 29, 2009 05:09PM UTC by bugomat comment:5

resolution: invalid
status: closedreopened

I have the same problem, using FF 3.5.3 on XP.

I have the fb-1.4.5 ext + web developer toolbar 1.1.8

As it seems - the problem is (currently) the warning message itself, since the selector is working and the results are as they should be.

Changed December 29, 2009 07:56PM UTC by dmethvin comment:6

resolution: → worksforme
status: reopenedclosed

I have attached a minimal test case; be sure that "Show CSS Errors" is turned on in the console or the message will not appear.

For best performance, the selector

"option:selected"
is first passed to querySelectorAll in Sizzle, which is wrapped in a try/catch. Since
:selected
isn't a standard CSS pseudo, FF throws and also shows that console warning. Sizzle then parses the selector string itself and the resulting jQuery set is exactly what it should be.

By my reading, the W3C draft of the Selectors API recommends doing just what Sizzle is doing:

http://www.w3.org/TR/2009/CR-selectors-api-20091222/#interoperability

"Some implementations might have different levels of support for Selectors. If some implementations lack support for some selectors, then the use of such selectors will result in those implementations failing to return the expected results. Authors are advised to check for the DOM Exceptions thrown by these APIs and provide a fallback for graceful degradation."

There is no error or bug here, just a spurious warning on the console. Avoiding the message would require parsing the selector string to know whether it was suitable for querySelectorAll, which would impact performance. QSA already has a fast way to tell us selectors it doesn't recognize -- it throws an exception and we catch it.

Changed February 21, 2011 05:43PM UTC by waltersjack@gmail.com comment:7

One way to stop this warning (besides disabling it) is to complicate the check a little:

I was getting the error on an app where I was removing items when they were selected:

$("#[selectid] option:selected").each(function() {

$(this).remove();

});

I updated it to make the check inside the each function, and then there were no Firefox complaints:

$("#[selectid] option").each(function() {

if($(this).is(":selected")) {

$(this).remove();

}

});

Replying to [ticket:4774 Dan86]:

Every time a selector try to select the selected items in <select>, it throws a "Warning: Unknown pseudo-class or pseudo-element 'selected'." warning in the error console in Firefox. If you go to this page you can check it out, the warning is shown in there too: http://docs.jquery.com/Selectors/selected (using Firefox 3.5 Release Candidate)