Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Remove cases of :contains() where quotes are used - not using quotes …
…follows more closely with the CSS Selector recommendation.
- Loading branch information
Showing
1 changed file
with
6 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
d48db1f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which recommendation is that? I found this old thing:
http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#content-selectors
d48db1f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah - that's the old one that never made it to recommendation. As far as I'm able to determine all other pseudo-classes (as they call them) don't allow quotes inside the (...). I think it's pretty safe since this is a custom selector and at this point we at least try to get into the current convention style (of not using quotes). I'm referring to the current recommendation here: http://www.w3.org/TR/css3-selectors/
d48db1f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well some allow
identifiers
, like :lang, with no quotes but they are different thanstrings
and would require proper escaping for spaces and things. I think the old link has it correct ascontains()
should be treated like the attribute selector and allow strings, single or double quoted, as its purpose isn't really for identifiers.d48db1f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jeresig,
quoted, unquoted, identifier, string ... this is not just related to ':contains()' pseudo-class (which never made in the specifications) it is a more general misunderstanding of the specifications through all jQuery/Sizzle selectors code, @jdalton correctly points out some of these.
The specifications you are pointing to explicitly states:
Attribute values must be CSS identifiers or strings. [CSS21] The case-sensitivity of attribute names and values in selectors depends on the document language.
you can read there what an "identifier" and what a "string" are in CSS selectors, this points back to CSS21 syntax rules so quite old and stable).
"strings" can be defined so only if they are quoted (single or double), unquoted strings do not exists, in that case they (maybe) are "identifiers".
"identifiers" syntax is different, it only allows certain range of characters and the start char must be "-?[a-zA-Z]" (can be escaped etc...).
Since you are pointing there with specs at hand, another minor problem is related to the currently allowed Unicode char range in jQuery/Sizzle.
As for specifications you linked to, the correct regular expression (for that Unicode part) is not [\u00c0-\uFFFF-] but [\u00A1-\uFFFF](all upper case or all lower case letters as you prefer, better not mix them for consistency).