diff --git a/lib/parser/function/var.js b/lib/parser/function/var.js index 492b2ddf..8c1a7e7f 100644 --- a/lib/parser/function/var.js +++ b/lib/parser/function/var.js @@ -26,7 +26,10 @@ module.exports = function getVarFunction() { if (this.scanner.tokenType === COMMA) { children.appendData(this.Operator()); - children.appendData(this.Raw(BALANCED, HYPHENMINUS, EXCLAMATIONMARK)); + children.appendData(this.parseCustomProperty + ? this.Value(null) + : this.Raw(BALANCED, HYPHENMINUS, EXCLAMATIONMARK) + ); } return children; diff --git a/test/fixture/parse/value/Value.json b/test/fixture/parse/value/Value.json index 09ae2e11..f3d03595 100644 --- a/test/fixture/parse/value/Value.json +++ b/test/fixture/parse/value/Value.json @@ -144,6 +144,29 @@ ] } }, + "should parse a custom property value when parseCustomProperty is true": { + "options": { + "property": "--var", + "parseCustomProperty": true + }, + "source": "1 foo", + "ast": { + "type": "Value", + "children": [ + { + "type": "Number", + "value": "1" + }, + { + "type": "Space" + }, + { + "type": "Identifier", + "name": "foo" + } + ] + } + }, "error": [ { "comment": "closing parenthesis is not allowed", diff --git a/test/fixture/parse/value/function/var.json b/test/fixture/parse/value/function/var.json index bd98a7b0..9fba7642 100644 --- a/test/fixture/parse/value/function/var.json +++ b/test/fixture/parse/value/function/var.json @@ -160,6 +160,43 @@ ] } }, + "should parse a fallback value when parseCustomProperty is true": { + "options": { + "parseCustomProperty": true + }, + "source": "var(--foo, 1 foo)", + "translate": "var(--foo,1 foo)", + "ast": { + "type": "Function", + "name": "var", + "children": [ + { + "type": "Identifier", + "name": "--foo" + }, + { + "type": "Operator", + "value": "," + }, + { + "type": "Value", + "children": [ + { + "type": "Number", + "value": "1" + }, + { + "type": "Space" + }, + { + "type": "Identifier", + "name": "foo" + } + ] + } + ] + } + }, "error #1": { "source": "var(name)", "offset": " ^",