From b09fdb443876f3bd5f288d3c3169982a125e8546 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 24 Mar 2019 21:48:06 -0700 Subject: [PATCH] [scss] Add support for interpolation of custom properties --- src/scss/parse.js | 4 +- test/scss/declaration/custom.property.7.json | 109 +++++++++++++++++++ test/scss/declaration/custom.property.7.scss | 1 + test/scss/declaration/test.coffee | 1 + 4 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 test/scss/declaration/custom.property.7.json create mode 100644 test/scss/declaration/custom.property.7.scss diff --git a/src/scss/parse.js b/src/scss/parse.js index 924ff4bc..b1c2e3ec 100644 --- a/src/scss/parse.js +++ b/src/scss/parse.js @@ -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; @@ -3483,7 +3483,7 @@ function getCustomProperty() { // Skip `--` pos += 2; - const content = [getIdent()]; + const content = getIdentOrInterpolation(); return newNode(type, content, line, column); } diff --git a/test/scss/declaration/custom.property.7.json b/test/scss/declaration/custom.property.7.json new file mode 100644 index 00000000..36e39520 --- /dev/null +++ b/test/scss/declaration/custom.property.7.json @@ -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 + } +} diff --git a/test/scss/declaration/custom.property.7.scss b/test/scss/declaration/custom.property.7.scss new file mode 100644 index 00000000..ca45f1bb --- /dev/null +++ b/test/scss/declaration/custom.property.7.scss @@ -0,0 +1 @@ +--#{$foo}:bar diff --git a/test/scss/declaration/test.coffee b/test/scss/declaration/test.coffee index 75c6e66a..72bb807a 100644 --- a/test/scss/declaration/test.coffee +++ b/test/scss/declaration/test.coffee @@ -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()