csslint: Selectors L4 parts (ED 2020-04-07) (#981)

* add :where(), remove :matches()

* add "s" case-sensitivity flag

* add "||" column combinator
This commit is contained in:
tophf 2020-06-26 19:47:12 +03:00 committed by GitHub
parent 4e146d0e54
commit 429c34ca8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1426,12 +1426,13 @@ self.parserlib = (() => {
GREATER: {text: '>'},
COMMA: {text: ','},
TILDE: {text: '~'},
COLUMN: {text: '||'},
// modifier
NOT: {},
ANY: {text: ['any', '-webkit-any', '-moz-any']},
MATCHES: {},
IS: {},
WHERE: {},
/*
* Defined in CSS3 Paged Media
@ -1468,7 +1469,6 @@ self.parserlib = (() => {
// part of CSS3 grammar but not the Flex code
CHAR: {},
// TODO: Needed?
// Not defined as tokens, but might as well be
PIPE: {text: '|'},
SLASH: {text: '/'},
@ -2205,6 +2205,7 @@ self.parserlib = (() => {
value === '>' ? 'child' :
value === '+' ? 'adjacent-sibling' :
value === '~' ? 'sibling' :
value === '||' ? 'column' :
!value.trim() ? 'descendant' :
'unknown';
}
@ -2943,6 +2944,7 @@ self.parserlib = (() => {
* - PREFIXMATCH
* - SUFFIXMATCH
* - SUBSTRINGMATCH
* - COLUMN
* - CHAR
*/
case '|':
@ -2950,10 +2952,11 @@ self.parserlib = (() => {
case '^':
case '$':
case '*':
return reader.peek() === '=' ?
this.comparisonToken(c, pos) :
this.charToken(c, pos);
return (
reader.peek() === '=' ? this.comparisonToken(c, pos) :
reader.readMatch('|') ? this.createToken(Tokens.COLUMN, '||', pos) :
this.charToken(c, pos)
);
/*
* Potential tokens:
* - STRING
@ -3043,8 +3046,8 @@ self.parserlib = (() => {
* Potential tokens:
* - ANY
* - IS
* - MATCHES
* - NOT
* - WHERE
* - CHAR
*/
case ':':
@ -3258,18 +3261,18 @@ self.parserlib = (() => {
// NOT
// IS
// ANY
// MATCHES
// CHAR
notOrIsToken(first, pos) {
// first is always ':'
const reader = this._reader;
const func = reader.readMatch(/(not|is|(-(moz|webkit)-)?(any|matches))\(/iy);
const func = reader.readMatch(/(not|is|where|(-(moz|webkit)-)?any)\(/iy);
if (func) {
const lcase = func[0].toLowerCase();
const type =
lcase === 'n' ? Tokens.NOT :
lcase === 'i' ? Tokens.IS :
lcase === 'm' ? Tokens.MATCHES : Tokens.ANY;
lcase === 'w' ? Tokens.WHERE :
Tokens.ANY;
return this.createToken(type, first + func, pos);
}
return this.charToken(first, pos);
@ -4369,7 +4372,7 @@ self.parserlib = (() => {
}
_combinator() {
if (this._tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE])) {
if (this._tokenStream.match([Tokens.PLUS, Tokens.GREATER, Tokens.TILDE, Tokens.COLUMN])) {
const value = new Combinator(this._tokenStream._token);
this._ws();
return value;
@ -4633,7 +4636,8 @@ self.parserlib = (() => {
this._ws();
if (stream.match([Tokens.IDENT])) {
if (lower(stream._token.value) === 'i') {
const caseMod = lower(stream._token.value);
if (caseMod === 'i' || caseMod === 's') {
value += stream._token.value +
this._ws();
} else {
@ -4713,7 +4717,7 @@ self.parserlib = (() => {
_is() {
const stream = this._tokenStream;
if (!stream.match([Tokens.IS, Tokens.ANY, Tokens.MATCHES])) return null;
if (!stream.match([Tokens.IS, Tokens.ANY, Tokens.WHERE])) return null;
let arg;
const start = stream._token;
@ -5448,7 +5452,7 @@ self.parserlib = (() => {
[Tokens.COLON, Parser.prototype._pseudo],
[Tokens.IS, Parser.prototype._is],
[Tokens.ANY, Parser.prototype._is],
[Tokens.MATCHES, Parser.prototype._is],
[Tokens.WHERE, Parser.prototype._is],
[Tokens.NOT, Parser.prototype._negation],
]),
};