From 696690c8daceba2354de59a1bc9d7a03968926f4 Mon Sep 17 00:00:00 2001 From: tophf Date: Wed, 28 Feb 2018 20:53:50 +0300 Subject: [PATCH] show invalid :not() as a nonfatal error (#357) --- vendor-overwrites/csslint/parserlib.js | 43 ++++++++++---------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/vendor-overwrites/csslint/parserlib.js b/vendor-overwrites/csslint/parserlib.js index 442d8faa..33e8e960 100644 --- a/vendor-overwrites/csslint/parserlib.js +++ b/vendor-overwrites/csslint/parserlib.js @@ -4674,39 +4674,28 @@ self.parserlib = (() => { if (!stream.match(Tokens.NOT)) return null; const start = stream._token; - let value = stream._token.value + this._ws(); + let value = start.value + this._ws(); - const arg = this._negationArg(); - value += arg + this._ws(); - - stream.match(Tokens.RPAREN); - value += stream._token.value; + const arg = this._selectorsGroup(); + if (!arg) this._unexpectedToken(stream.LT(1)); + const parts = arg[0].parts; + if (arg.length > 1 || + parts.length !== 1 || + parts[0].modifiers.length + (parts[0].elementName ? 1 : 0) > 1 || + /^:not\b/i.test(parts[0])) { + this.fire({ + type: 'error', + message: `Simple selector expected, but found '${arg.join(', ')}'`, + }, arg[0]); + } + value += arg[0] + this._ws() + ')'; + stream.mustMatch(Tokens.RPAREN); const subpart = new SelectorSubPart(value, 'not', start); - subpart.args.push(arg); + subpart.args.push(arg[0]); return subpart; } - _negationArg() { - const stream = this._tokenStream; - const start = stream.LT(1); - const next = stream.peek(); - const ns = this._namespacePrefix(); - const arg = - this._typeSelector(ns) || - this._universal(ns) || - next === Tokens.HASH && this._hash() || - next === Tokens.DOT && this._class() || - next === Tokens.LBRACKET && this._attrib() || - next === Tokens.COLON && this._pseudo(); - - if (!arg) this._unexpectedToken(stream.LT(1)); - - return arg.type === 'elementName' ? - new SelectorPart(arg, [], arg.toString(), start) : - new SelectorPart(null, [arg], arg.toString(), start); - } - _declaration(consumeSemicolon) { const stream = this._tokenStream;