Skip to content

Commit

Permalink
fix parsing var() fallback value when parseCustomProperty is true
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Feb 5, 2017
1 parent 11412b1 commit 5526817
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/parser/function/var.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions test/fixture/parse/value/Value.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
37 changes: 37 additions & 0 deletions test/fixture/parse/value/function/var.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": " ^",
Expand Down

0 comments on commit 5526817

Please sign in to comment.