parserlib: fix ieFunction

fixes #1325
This commit is contained in:
tophf 2021-08-26 22:03:05 +03:00
parent a5a8d97767
commit abced603b4

View File

@ -251,7 +251,7 @@ self.parserlib = (() => {
'fill': '<paint>', 'fill': '<paint>',
'fill-opacity': '<opacity-value>', 'fill-opacity': '<opacity-value>',
'fill-rule': 'nonzero | evenodd', 'fill-rule': 'nonzero | evenodd',
'filter': '<filter-function-list> | none', 'filter': '<filter-function-list> | <ie-function> | none',
'fit': 'fill | hidden | meet | slice', 'fit': 'fill | hidden | meet | slice',
'fit-position': 1, 'fit-position': 1,
'flex': '<flex-shorthand>', 'flex': '<flex-shorthand>',
@ -762,6 +762,7 @@ self.parserlib = (() => {
!/^(span|auto|default)$/i.test(p.value), !/^(span|auto|default)$/i.test(p.value),
'<ident-not-generic-family>': p => vtIsIdent(p) && !VTSimple['<generic-family>'](p), '<ident-not-generic-family>': p => vtIsIdent(p) && !VTSimple['<generic-family>'](p),
'<ident-not-none>': p => vtIsIdent(p) && !lowerCmp(p.value, 'none'), '<ident-not-none>': p => vtIsIdent(p) && !lowerCmp(p.value, 'none'),
'<ie-function>': p => p.tokenType === Tokens.IE_FUNCTION, //eslint-disable-line no-use-before-define
'<image>': '<uri> | <gradient> | cross-fade()', '<image>': '<uri> | <gradient> | cross-fade()',
'<inflexible-breadth>': '<length-pct> | min-content | max-content | auto', '<inflexible-breadth>': '<length-pct> | min-content | max-content | auto',
'<integer>': p => p.isInt || p.isCalc, '<integer>': p => p.isInt || p.isCalc,
@ -4157,8 +4158,9 @@ self.parserlib = (() => {
} }
return new PropertyValuePart(token); return new PropertyValuePart(token);
}; };
if (this.options.ieFilters && stream.peek() === Tokens.IE_FUNCTION) { const next = this.options.ieFilters && stream.LT(1);
return finalize(this._ieFunction()); if (next && next.type === Tokens.IE_FUNCTION) {
return finalize(next, this._ieFunction());
} }
// see if it's a simple block // see if it's a simple block
if (stream.match(inFunction ? TT.LParenBracketBrace : TT.LParenBracket)) { if (stream.match(inFunction ? TT.LParenBracketBrace : TT.LParenBracket)) {
@ -4230,36 +4232,25 @@ self.parserlib = (() => {
_ieFunction() { _ieFunction() {
const stream = this._tokenStream; const stream = this._tokenStream;
let functionText = null; const text = [];
let lt;
// IE function can begin like a regular function, too // IE function can begin like a regular function, too
if (stream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])) { if (stream.match([Tokens.IE_FUNCTION, Tokens.FUNCTION])) {
functionText = stream._token.value; text.push(stream._token.value);
do { do {
if (this._ws()) { text.push(
functionText += stream._token.value; stream._token.value === ',' ? ',' : '', // subsequent loops
} this._ws(),
// might be second time in the loop stream.match(Tokens.IDENT).value || '',
if (stream.LA(0) === Tokens.COMMA) { stream.match(Tokens.EQUALS).value || '');
functionText += stream._token.value; // functionText.push(this._term());
} while (!/^([,)]|\s+)$/.test(stream.LT(1).value)) {
stream.match(Tokens.IDENT); text.push(stream.get(true).value);
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();
} }
} while (stream.match([Tokens.COMMA, Tokens.S])); } while (stream.match([Tokens.COMMA, Tokens.S]));
stream.match(Tokens.RPAREN); text.push(stream.match(Tokens.RPAREN).value);
functionText += ')';
this._ws(); this._ws();
} }
return functionText; return fastJoin(text) || null;
} }
_hexcolor() { _hexcolor() {