From abced603b4b0f59ca21e994802699718aaa7e406 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 26 Aug 2021 22:03:05 +0300 Subject: [PATCH] parserlib: fix ieFunction fixes #1325 --- js/csslint/parserlib.js | 43 ++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/js/csslint/parserlib.js b/js/csslint/parserlib.js index 0a0f7d13..fe43aa79 100644 --- a/js/csslint/parserlib.js +++ b/js/csslint/parserlib.js @@ -251,7 +251,7 @@ self.parserlib = (() => { 'fill': '', 'fill-opacity': '', 'fill-rule': 'nonzero | evenodd', - 'filter': ' | none', + 'filter': ' | | none', 'fit': 'fill | hidden | meet | slice', 'fit-position': 1, 'flex': '', @@ -762,6 +762,7 @@ self.parserlib = (() => { !/^(span|auto|default)$/i.test(p.value), '': p => vtIsIdent(p) && !VTSimple[''](p), '': p => vtIsIdent(p) && !lowerCmp(p.value, 'none'), + '': p => p.tokenType === Tokens.IE_FUNCTION, //eslint-disable-line no-use-before-define '': ' | | cross-fade()', '': ' | min-content | max-content | auto', '': p => p.isInt || p.isCalc, @@ -4157,8 +4158,9 @@ self.parserlib = (() => { } return new PropertyValuePart(token); }; - if (this.options.ieFilters && stream.peek() === Tokens.IE_FUNCTION) { - return finalize(this._ieFunction()); + const next = this.options.ieFilters && stream.LT(1); + if (next && next.type === Tokens.IE_FUNCTION) { + return finalize(next, this._ieFunction()); } // see if it's a simple block if (stream.match(inFunction ? TT.LParenBracketBrace : TT.LParenBracket)) { @@ -4230,36 +4232,25 @@ self.parserlib = (() => { _ieFunction() { const stream = this._tokenStream; - let functionText = null; - let lt; + const text = []; // IE function can begin like a regular function, too if (stream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])) { - functionText = stream._token.value; + text.push(stream._token.value); do { - if (this._ws()) { - functionText += stream._token.value; - } - // might be second time in the loop - if (stream.LA(0) === Tokens.COMMA) { - functionText += stream._token.value; - } - stream.match(Tokens.IDENT); - functionText += stream._token.value; - stream.match(Tokens.EQUALS); - functionText += stream._token.value; - // functionText += this._term(); - lt = stream.peek(); - while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN) { - stream.get(); - functionText += stream._token.value; - lt = stream.peek(); + text.push( + stream._token.value === ',' ? ',' : '', // subsequent loops + this._ws(), + stream.match(Tokens.IDENT).value || '', + stream.match(Tokens.EQUALS).value || ''); + // functionText.push(this._term()); + while (!/^([,)]|\s+)$/.test(stream.LT(1).value)) { + text.push(stream.get(true).value); } } while (stream.match([Tokens.COMMA, Tokens.S])); - stream.match(Tokens.RPAREN); - functionText += ')'; + text.push(stream.match(Tokens.RPAREN).value); this._ws(); } - return functionText; + return fastJoin(text) || null; } _hexcolor() {