Bug Tracker

Modify

Ticket #4774 (closed bug: worksforme)

Opened 4 years ago

Last modified 2 years ago

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:
Blocking: Blocked by:

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

test-4774.html Download (557 bytes) - added by dmethvin 3 years ago.
Repro for #4774 on FF 3.5.

Change History

comment:1 Changed 4 years ago by dmethvin

  • Status changed from new to closed
  • Resolution set to invalid

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

comment:2 Changed 4 years ago by geckoneer

  • Status changed from closed to reopened
  • Resolution invalid deleted

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

comment:3 Changed 4 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 4 years ago by john

  • Status changed from reopened to closed
  • Resolution set to invalid

comment:6 Changed 3 years ago by bugomat

  • Status changed from closed to reopened
  • Resolution invalid deleted

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

Repro for #4774 on FF 3.5.

comment:7 Changed 3 years ago by dmethvin

  • Status changed from reopened to closed
  • Resolution set to worksforme

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

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.