Skip to content

Commit

Permalink
[scss] Add support for interpolation of custom properties
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalton committed Mar 25, 2019
1 parent a392a88 commit b09fdb4
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/scss/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -3464,7 +3464,7 @@ function checkCustomProperty(i) {
// Skip `--`
i += 2;

if (l = checkIdent(i)) i += l;
if (l = checkIdentOrInterpolation(i)) i += l;
else return 0;

return i - start;
Expand All @@ -3483,7 +3483,7 @@ function getCustomProperty() {
// Skip `--`
pos += 2;

const content = [getIdent()];
const content = getIdentOrInterpolation();

return newNode(type, content, line, column);
}
Expand Down
109 changes: 109 additions & 0 deletions test/scss/declaration/custom.property.7.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"type": "declaration",
"content": [
{
"type": "customProperty",
"content": [
{
"type": "interpolation",
"content": [
{
"type": "variable",
"content": [
{
"type": "ident",
"content": "foo",
"syntax": "scss",
"start": {
"line": 1,
"column": 6
},
"end": {
"line": 1,
"column": 8
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 5
},
"end": {
"line": 1,
"column": 8
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 3
},
"end": {
"line": 1,
"column": 9
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 9
}
},
{
"type": "propertyDelimiter",
"content": ":",
"syntax": "scss",
"start": {
"line": 1,
"column": 10
},
"end": {
"line": 1,
"column": 10
}
},
{
"type": "value",
"content": [
{
"type": "ident",
"content": "bar",
"syntax": "scss",
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 13
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 11
},
"end": {
"line": 1,
"column": 13
}
}
],
"syntax": "scss",
"start": {
"line": 1,
"column": 1
},
"end": {
"line": 1,
"column": 13
}
}
1 change: 1 addition & 0 deletions test/scss/declaration/custom.property.7.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--#{$foo}:bar
1 change: 1 addition & 0 deletions test/scss/declaration/test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe 'scss/declaration >>', ->
it 'custom.property.4', -> this.shouldBeOk()
it 'custom.property.5', -> this.shouldBeOk()
it 'custom.property.6', -> this.shouldBeOk()
it 'custom.property.7', -> this.shouldBeOk()

it 'filter.0', -> this.shouldBeOk()
it 'filter.1', -> this.shouldBeOk()
Expand Down

0 comments on commit b09fdb4

Please sign in to comment.