CSSLint: expose function's inner expression

This commit is contained in:
tophf 2017-12-26 11:50:29 +03:00
parent e4f8cf5fb5
commit b8d1a0a9ff

View File

@ -1755,6 +1755,7 @@ Parser.prototype = function() {
this._readWhitespace(); this._readWhitespace();
} else { } else {
value = this._function(); value = this._function();
value = value && value.text;
} }
return value; return value;
@ -2816,6 +2817,10 @@ Parser.prototype = function() {
value = this._ie_function(); value = this._ie_function();
} else { } else {
value = this._function(); value = this._function();
if (value) {
part = new PropertyValuePart(unary !== null ? unary + value.text : value.text, line, col);
part.expr = value.expr;
}
} }
} }
@ -2847,7 +2852,7 @@ Parser.prototype = function() {
}, },
_function: function() { _function() {
/* /*
* function * function
@ -2856,40 +2861,40 @@ Parser.prototype = function() {
*/ */
var tokenStream = this._tokenStream, var tokenStream = this._tokenStream,
functionText = null, functionText = [],
expr = null, expr = null,
lt; lt;
if (tokenStream.match(Tokens.FUNCTION)) { if (tokenStream.match(Tokens.FUNCTION)) {
functionText = tokenStream.token().value; functionText.push(tokenStream.token().value);
this._readWhitespace(); this._readWhitespace();
expr = this._expr(true); expr = this._expr(true);
functionText += expr; functionText.push(String(expr));
//START: Horrible hack in case it's an IE filter //START: Horrible hack in case it's an IE filter
if (this.options.ieFilters && tokenStream.peek() === Tokens.EQUALS) { if (this.options.ieFilters && tokenStream.peek() === Tokens.EQUALS) {
do { do {
if (this._readWhitespace()) { if (this._readWhitespace()) {
functionText += tokenStream.token().value; functionText.push(tokenStream.token().value);
} }
//might be second time in the loop //might be second time in the loop
if (tokenStream.LA(0) === Tokens.COMMA) { if (tokenStream.LA(0) === Tokens.COMMA) {
functionText += tokenStream.token().value; functionText.push(tokenStream.token().value);
} }
tokenStream.match(Tokens.IDENT); tokenStream.match(Tokens.IDENT);
functionText += tokenStream.token().value; functionText.push(tokenStream.token().value);
tokenStream.match(Tokens.EQUALS); tokenStream.match(Tokens.EQUALS);
functionText += tokenStream.token().value; functionText.push(tokenStream.token().value);
//functionText += this._term(); //functionText.push(this._term());
lt = tokenStream.peek(); lt = tokenStream.peek();
while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN && lt !== Tokens.EOF) { while (lt !== Tokens.COMMA && lt !== Tokens.S && lt !== Tokens.RPAREN && lt !== Tokens.EOF) {
tokenStream.get(); tokenStream.get();
functionText += tokenStream.token().value; functionText.push(tokenStream.token().value);
lt = tokenStream.peek(); lt = tokenStream.peek();
} }
} while (tokenStream.match([Tokens.COMMA, Tokens.S])); } while (tokenStream.match([Tokens.COMMA, Tokens.S]));
@ -2898,11 +2903,11 @@ Parser.prototype = function() {
//END: Horrible Hack //END: Horrible Hack
tokenStream.mustMatch(Tokens.RPAREN); tokenStream.mustMatch(Tokens.RPAREN);
functionText += ")"; functionText.push(")");
this._readWhitespace(); this._readWhitespace();
} }
return functionText; return !functionText[0] ? null : {expr, text: functionText.join('')};
}, },
_ie_function: function() { _ie_function: function() {