Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#4774 closed bug (worksforme)

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 (557 bytes) - added by dmethvin 10 years ago.
Repro for #4774 on FF 3.5.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 10 years ago by dmethvin

Resolution: invalid
Status: newclosed

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

comment:2 Changed 10 years ago by geckoneer

Resolution: invalid
Status: closedreopened

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

comment:3 Changed 10 years ago by dmethvin

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.

comment:5 Changed 10 years ago by john

Resolution: invalid
Status: reopenedclosed

comment:6 Changed 10 years ago by bugomat

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 10 years ago by dmethvin

Attachment: test-4774.html added

Repro for #4774 on FF 3.5.

comment:7 Changed 10 years ago by dmethvin

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.

comment:8 in reply to:  description Changed 9 years ago by waltersjack@…

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 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)

Note: See TracTickets for help on using tickets.