diff --git a/src/css/parse.js b/src/css/parse.js index 654c86e5..06aada19 100644 --- a/src/css/parse.js +++ b/src/css/parse.js @@ -446,13 +446,15 @@ function checkAtrule(i) { // If token is part of an @-rule, save the rule's type to token. // @keyframes: - if (l = checkKeyframesRule(i)) tokens[i].atrule_type = 4; + if (l = checkKeyframesRule(i)) tokens[i].atrule_type = 1; + // @apply --custom-property: + else if (l = checkApplyRule(i)) tokens[i].atrule_type = 2; // @-rule with ruleset: - else if (l = checkAtruler(i)) tokens[i].atrule_type = 1; + else if (l = checkAtruler(i)) tokens[i].atrule_type = 3; // Block @-rule: - else if (l = checkAtruleb(i)) tokens[i].atrule_type = 2; + else if (l = checkAtruleb(i)) tokens[i].atrule_type = 4; // Single-line @-rule: - else if (l = checkAtrules(i)) tokens[i].atrule_type = 3; + else if (l = checkAtrules(i)) tokens[i].atrule_type = 5; else return 0; // If token is part of an @-rule, save the rule's length to token: @@ -468,10 +470,11 @@ function checkAtrule(i) { function getAtrule() { const childType = tokens[pos].atrule_type; - if (childType === 1) return getAtruler(); // @-rule with ruleset - if (childType === 2) return getAtruleb(); // Block @-rule - if (childType === 3) return getAtrules(); // Single-line @-rule - if (childType === 4) return getKeyframesRule(); + if (childType === 1) return getKeyframesRule(); + if (childType === 2) return getApplyRule(); + if (childType === 3) return getAtruler(); // @-rule with ruleset + if (childType === 4) return getAtruleb(); // Block @-rule + if (childType === 5) return getAtrules(); // Single-line @-rule } /** @@ -653,6 +656,47 @@ function getAtrules() { return newNode(type, content, line, column); } +/** + * @param {Number} i Token's index number + * @returns {Number} + */ +function checkApplyRule(i) { + const start = i; + let l; + + if (i >= tokensLength) return 0; + + if (l = checkAtkeyword(i)) i += l; + else return 0; + + const atruleName = joinValues2(i - l, l); + if (atruleName.toLowerCase().indexOf('apply') === -1) return 0; + + if (l = checkSC(i)) i += l; + + if (l = checkCustomProperty(i)) i += l; + else return 0; + + return i - start; +} + +/** + * @returns {Node} + */ +function getApplyRule() { + const type = NodeType.AtruleType; + const token = tokens[pos]; + const line = token.ln; + const column = token.col; + let content = [].concat( + getAtkeyword(), + getSC(), + getCustomProperty() + ); + + return newNode(type, content, line, column); +} + /** * Check if token is part of a block (e.g. `{...}`). * @param {Number} i Token's index number @@ -2285,11 +2329,11 @@ function checkPseudoc(i) { if (i >= tokensLength || tokens[i].type !== TokenType.Colon) return 0; - if (l = checkPseudoClass1(i)) tokens[i].pseudoClassType = 1; - else if (l = checkPseudoClass2(i)) tokens[i].pseudoClassType = 2; - else if (l = checkPseudoClass3(i)) tokens[i].pseudoClassType = 3; + if (l = checkPseudoClass3(i)) tokens[i].pseudoClassType = 3; else if (l = checkPseudoClass4(i)) tokens[i].pseudoClassType = 4; else if (l = checkPseudoClass5(i)) tokens[i].pseudoClassType = 5; + else if (l = checkPseudoClass1(i)) tokens[i].pseudoClassType = 1; + else if (l = checkPseudoClass2(i)) tokens[i].pseudoClassType = 2; else if (l = checkPseudoClass6(i)) tokens[i].pseudoClassType = 6; else return 0; @@ -3343,11 +3387,13 @@ function checkValue(i) { let _i; while (i < tokensLength) { + if (checkDeclDelim(i)) break; + s = checkSC(i); _i = i + s; if (l = _checkValue(_i)) i += l + s; - else break; + if (!l || checkBlock(i - l)) break; } tokens[start].value_end = i; @@ -3365,10 +3411,21 @@ function getValue() { const column = token.col; const end = tokens[pos].value_end; let content = []; + let _pos; + let s; while (pos < end) { - if (tokens[pos].value_child) content.push(_getValue()); - else content = content.concat(getSC()); + s = checkSC(pos); + _pos = pos + s; + + if (checkDeclDelim(_pos)) break; + + if (!_checkValue(_pos)) break; + + if (s) content = content.concat(getSC()); + content.push(_getValue()); + + if (checkBlock(_pos)) break; } return newNode(type, content, line, column); @@ -3383,9 +3440,10 @@ function _checkValue(i) { if (l = checkProgid(i)) tokens[i].value_child = 1; else if (l = checkVhash(i)) tokens[i].value_child = 2; - else if (l = checkAny(i)) tokens[i].value_child = 3; + else if (l = checkBlock(i)) tokens[i].value_child = 3; else if (l = checkOperator(i)) tokens[i].value_child = 4; else if (l = checkImportant(i)) tokens[i].value_child = 5; + else if (l = checkAny(i)) tokens[i].value_child = 6; return l; } @@ -3397,9 +3455,10 @@ function _getValue() { const childType = tokens[pos].value_child; if (childType === 1) return getProgid(); if (childType === 2) return getVhash(); - if (childType === 3) return getAny(); + if (childType === 3) return getBlock(); if (childType === 4) return getOperator(); if (childType === 5) return getImportant(); + if (childType === 6) return getAny(); } /** diff --git a/src/sass/parse.js b/src/sass/parse.js index ecbed155..4e590e8a 100644 --- a/src/sass/parse.js +++ b/src/sass/parse.js @@ -589,13 +589,15 @@ function checkAtrule(i) { // If token is part of an @-rule, save the rule's type to token. // @keyframes: - if (l = checkKeyframesRule(i)) tokens[i].atrule_type = 4; + if (l = checkKeyframesRule(i)) tokens[i].atrule_type = 1; + // @apply --custom-property: + else if (l = checkApplyRule(i)) tokens[i].atrule_type = 2; // @-rule with ruleset: - else if (l = checkAtruler(i)) tokens[i].atrule_type = 1; + else if (l = checkAtruler(i)) tokens[i].atrule_type = 3; // Block @-rule: - else if (l = checkAtruleb(i)) tokens[i].atrule_type = 2; + else if (l = checkAtruleb(i)) tokens[i].atrule_type = 4; // Single-line @-rule: - else if (l = checkAtrules(i)) tokens[i].atrule_type = 3; + else if (l = checkAtrules(i)) tokens[i].atrule_type = 5; else return 0; // If token is part of an @-rule, save the rule's length to token: @@ -612,10 +614,11 @@ function checkAtrule(i) { function getAtrule() { const childType = tokens[pos].atrule_type; - if (childType === 1) return getAtruler(); // @-rule with ruleset - if (childType === 2) return getAtruleb(); // Block @-rule - if (childType === 3) return getAtrules(); // Single-line @-rule - if (childType === 4) return getKeyframesRule(); + if (childType === 1) return getKeyframesRule(); + if (childType === 2) return getApplyRule(); + if (childType === 3) return getAtruler(); // @-rule with ruleset + if (childType === 4) return getAtruleb(); // Block @-rule + if (childType === 5) return getAtrules(); // Single-line @-rule } /** @@ -785,6 +788,47 @@ function getAtrules() { return newNode(type, content, line, column); } +/** + * @param {Number} i Token's index number + * @returns {Number} + */ +function checkApplyRule(i) { + const start = i; + let l; + + if (i >= tokensLength) return 0; + + if (l = checkAtkeyword(i)) i += l; + else return 0; + + const atruleName = joinValues2(i - l, l); + if (atruleName.toLowerCase().indexOf('apply') === -1) return 0; + + if (l = checkSC(i)) i += l; + + if (l = checkCustomProperty(i)) i += l; + else return 0; + + return i - start; +} + +/** + * @returns {Node} + */ +function getApplyRule() { + const type = NodeType.AtruleType; + const token = tokens[pos]; + const line = token.ln; + const column = token.col; + let content = [].concat( + getAtkeyword(), + getSC(), + getCustomProperty() + ); + + return newNode(type, content, line, column); +} + /** * Checks if token is part of a block (e.g. `{...}`). * @@ -874,7 +918,7 @@ function checkBlockdecl1(i) { [2, 4, 6, 8].indexOf(tokens[start].include_type) === -1) return 0; if (tokens[start].bd_kind === 6 && - tokens[start].atrule_type === 3) return 0; + tokens[start].atrule_type === 5) return 0; while (i < tokensLength) { if (l = checkDeclDelim(i)) diff --git a/src/scss/parse.js b/src/scss/parse.js index d6204a18..852f6bba 100644 --- a/src/scss/parse.js +++ b/src/scss/parse.js @@ -557,13 +557,15 @@ function checkAtrule(i) { // If token is part of an @-rule, save the rule's type to token. // @keyframes: - if (l = checkKeyframesRule(i)) tokens[i].atrule_type = 4; + if (l = checkKeyframesRule(i)) tokens[i].atrule_type = 1; + // @apply --custom-property: + else if (l = checkApplyRule(i)) tokens[i].atrule_type = 2; // @-rule with ruleset: - else if (l = checkAtruler(i)) tokens[i].atrule_type = 1; + else if (l = checkAtruler(i)) tokens[i].atrule_type = 3; // Block @-rule: - else if (l = checkAtruleb(i)) tokens[i].atrule_type = 2; + else if (l = checkAtruleb(i)) tokens[i].atrule_type = 4; // Single-line @-rule: - else if (l = checkAtrules(i)) tokens[i].atrule_type = 3; + else if (l = checkAtrules(i)) tokens[i].atrule_type = 5; else return 0; // If token is part of an @-rule, save the rule's length to token: @@ -579,10 +581,11 @@ function checkAtrule(i) { function getAtrule() { const childType = tokens[pos].atrule_type; - if (childType === 1) return getAtruler(); // @-rule with ruleset - if (childType === 2) return getAtruleb(); // Block @-rule - if (childType === 3) return getAtrules(); // Single-line @-rule - if (childType === 4) return getKeyframesRule(); + if (childType === 1) return getKeyframesRule(); + if (childType === 2) return getApplyRule(); + if (childType === 3) return getAtruler(); // @-rule with ruleset + if (childType === 4) return getAtruleb(); // Block @-rule + if (childType === 5) return getAtrules(); // Single-line @-rule } /** @@ -764,6 +767,47 @@ function getAtrules() { return newNode(type, content, line, column); } +/** + * @param {Number} i Token's index number + * @returns {Number} + */ +function checkApplyRule(i) { + const start = i; + let l; + + if (i >= tokensLength) return 0; + + if (l = checkAtkeyword(i)) i += l; + else return 0; + + const atruleName = joinValues2(i - l, l); + if (atruleName.toLowerCase().indexOf('apply') === -1) return 0; + + if (l = checkSC(i)) i += l; + + if (l = checkCustomProperty(i)) i += l; + else return 0; + + return i - start; +} + +/** + * @returns {Node} + */ +function getApplyRule() { + const type = NodeType.AtruleType; + const token = tokens[pos]; + const line = token.ln; + const column = token.col; + let content = [].concat( + getAtkeyword(), + getSC(), + getCustomProperty() + ); + + return newNode(type, content, line, column); +} + /** * Check if token is part of a block (e.g. `{...}`). * @param {Number} i Token's index number diff --git a/test/css/atrule/14.css b/test/css/atrule/14.css new file mode 100644 index 00000000..ee381833 --- /dev/null +++ b/test/css/atrule/14.css @@ -0,0 +1 @@ +@apply --custom-property diff --git a/test/css/atrule/14.json b/test/css/atrule/14.json new file mode 100644 index 00000000..b92ce309 --- /dev/null +++ b/test/css/atrule/14.json @@ -0,0 +1,81 @@ +{ + "type": "atrule", + "content": [ + { + "type": "atkeyword", + "content": [ + { + "type": "ident", + "content": "apply", + "syntax": "css", + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 6 + } + } + ], + "syntax": "css", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + { + "type": "space", + "content": " ", + "syntax": "css", + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 7 + } + }, + { + "type": "customProperty", + "content": [ + { + "type": "ident", + "content": "custom-property", + "syntax": "css", + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 24 + } + } + ], + "syntax": "css", + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 24 + } + } + ], + "syntax": "css", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 24 + } +} diff --git a/test/css/atrule/test.coffee b/test/css/atrule/test.coffee index 6e261a76..65c88e86 100644 --- a/test/css/atrule/test.coffee +++ b/test/css/atrule/test.coffee @@ -14,6 +14,7 @@ describe 'css/atrule >>', -> it '11', -> this.shouldBeOk() it '12', -> this.shouldBeOk() it '13', -> this.shouldBeOk() + it '14', -> this.shouldBeOk() it 'c.0', -> this.shouldBeOk() it 'c.1', -> this.shouldBeOk() diff --git a/test/css/ruleset/9.css b/test/css/ruleset/9.css new file mode 100644 index 00000000..ed19f380 --- /dev/null +++ b/test/css/ruleset/9.css @@ -0,0 +1,5 @@ +:root { + --foo-bar: { + content: 'foobar'; + } +} diff --git a/test/css/ruleset/9.json b/test/css/ruleset/9.json new file mode 100644 index 00000000..91b4e36f --- /dev/null +++ b/test/css/ruleset/9.json @@ -0,0 +1,336 @@ +{ + "type": "ruleset", + "content": [ + { + "type": "selector", + "content": [ + { + "type": "pseudoClass", + "content": [ + { + "type": "ident", + "content": "root", + "syntax": "css", + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + } + ], + "syntax": "css", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + } + ], + "syntax": "css", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + { + "type": "space", + "content": " ", + "syntax": "css", + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 6 + } + }, + { + "type": "block", + "content": [ + { + "type": "space", + "content": "\n ", + "syntax": "css", + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 2 + } + }, + { + "type": "declaration", + "content": [ + { + "type": "customProperty", + "content": [ + { + "type": "ident", + "content": "foo-bar", + "syntax": "css", + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 11 + } + } + ], + "syntax": "css", + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 11 + } + }, + { + "type": "propertyDelimiter", + "content": ":", + "syntax": "css", + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 12 + } + }, + { + "type": "space", + "content": " ", + "syntax": "css", + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 13 + } + }, + { + "type": "value", + "content": [ + { + "type": "block", + "content": [ + { + "type": "space", + "content": "\n ", + "syntax": "css", + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 4 + } + }, + { + "type": "declaration", + "content": [ + { + "type": "property", + "content": [ + { + "type": "ident", + "content": "content", + "syntax": "css", + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 11 + } + } + ], + "syntax": "css", + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 11 + } + }, + { + "type": "propertyDelimiter", + "content": ":", + "syntax": "css", + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 12 + } + }, + { + "type": "space", + "content": " ", + "syntax": "css", + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 13 + } + }, + { + "type": "value", + "content": [ + { + "type": "string", + "content": "'foobar'", + "syntax": "css", + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 21 + } + } + ], + "syntax": "css", + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 21 + } + } + ], + "syntax": "css", + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 21 + } + }, + { + "type": "declarationDelimiter", + "content": ";", + "syntax": "css", + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 22 + } + }, + { + "type": "space", + "content": "\n ", + "syntax": "css", + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 4, + "column": 2 + } + } + ], + "syntax": "css", + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 4, + "column": 3 + } + } + ], + "syntax": "css", + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 4, + "column": 3 + } + } + ], + "syntax": "css", + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 4, + "column": 3 + } + }, + { + "type": "space", + "content": "\n", + "syntax": "css", + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 4 + } + } + ], + "syntax": "css", + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 5, + "column": 1 + } + } + ], + "syntax": "css", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 5, + "column": 1 + } +} diff --git a/test/css/ruleset/test.coffee b/test/css/ruleset/test.coffee index 61b14e43..778cbea9 100644 --- a/test/css/ruleset/test.coffee +++ b/test/css/ruleset/test.coffee @@ -9,6 +9,7 @@ describe 'css/ruleset >>', -> it '6', -> this.shouldBeOk() it '7', -> this.shouldBeOk() it '8', -> this.shouldBeOk() + it '9', -> this.shouldBeOk() it 'c.0', -> this.shouldBeOk() it 'c.1', -> this.shouldBeOk() diff --git a/test/sass/atrule/14.json b/test/sass/atrule/14.json new file mode 100644 index 00000000..32ab56ab --- /dev/null +++ b/test/sass/atrule/14.json @@ -0,0 +1,81 @@ +{ + "type": "atrule", + "content": [ + { + "type": "atkeyword", + "content": [ + { + "type": "ident", + "content": "apply", + "syntax": "sass", + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 6 + } + } + ], + "syntax": "sass", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + { + "type": "space", + "content": " ", + "syntax": "sass", + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 7 + } + }, + { + "type": "customProperty", + "content": [ + { + "type": "ident", + "content": "custom-property", + "syntax": "sass", + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 24 + } + } + ], + "syntax": "sass", + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 24 + } + } + ], + "syntax": "sass", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 24 + } +} diff --git a/test/sass/atrule/14.sass b/test/sass/atrule/14.sass new file mode 100644 index 00000000..ee381833 --- /dev/null +++ b/test/sass/atrule/14.sass @@ -0,0 +1 @@ +@apply --custom-property diff --git a/test/sass/atrule/test.coffee b/test/sass/atrule/test.coffee index 68bdd8b5..99a492b3 100644 --- a/test/sass/atrule/test.coffee +++ b/test/sass/atrule/test.coffee @@ -14,6 +14,7 @@ describe 'sass/atrule >>', -> it '11', -> this.shouldBeOk() it '12', -> this.shouldBeOk() it '13', -> this.shouldBeOk() + it '14', -> this.shouldBeOk() it 's.0', -> this.shouldBeOk() diff --git a/test/sass/ruleset/11.json b/test/sass/ruleset/11.json new file mode 100644 index 00000000..84a205c9 --- /dev/null +++ b/test/sass/ruleset/11.json @@ -0,0 +1,297 @@ +{ + "type": "ruleset", + "content": [ + { + "type": "selector", + "content": [ + { + "type": "pseudoClass", + "content": [ + { + "type": "ident", + "content": "root", + "syntax": "sass", + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + } + ], + "syntax": "sass", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + } + ], + "syntax": "sass", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + { + "type": "space", + "content": "\n", + "syntax": "sass", + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 6 + } + }, + { + "type": "block", + "content": [ + { + "type": "space", + "content": " ", + "syntax": "sass", + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 2 + } + }, + { + "type": "declaration", + "content": [ + { + "type": "customProperty", + "content": [ + { + "type": "ident", + "content": "foo-bar", + "syntax": "sass", + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 11 + } + } + ], + "syntax": "sass", + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 11 + } + }, + { + "type": "propertyDelimiter", + "content": ":", + "syntax": "sass", + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 12 + } + }, + { + "type": "space", + "content": "\n", + "syntax": "sass", + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 13 + } + }, + { + "type": "value", + "content": [ + { + "type": "block", + "content": [ + { + "type": "space", + "content": " ", + "syntax": "sass", + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 4 + } + }, + { + "type": "declaration", + "content": [ + { + "type": "property", + "content": [ + { + "type": "ident", + "content": "content", + "syntax": "sass", + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 11 + } + } + ], + "syntax": "sass", + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 11 + } + }, + { + "type": "propertyDelimiter", + "content": ":", + "syntax": "sass", + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 12 + } + }, + { + "type": "space", + "content": " ", + "syntax": "sass", + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 13 + } + }, + { + "type": "value", + "content": [ + { + "type": "string", + "content": "'foobar'", + "syntax": "sass", + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 21 + } + } + ], + "syntax": "sass", + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 21 + } + } + ], + "syntax": "sass", + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 21 + } + } + ], + "syntax": "sass", + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 21 + } + } + ], + "syntax": "sass", + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 21 + } + } + ], + "syntax": "sass", + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 3, + "column": 21 + } + } + ], + "syntax": "sass", + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 3, + "column": 21 + } + } + ], + "syntax": "sass", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 3, + "column": 21 + } +} diff --git a/test/sass/ruleset/11.sass b/test/sass/ruleset/11.sass new file mode 100644 index 00000000..33417418 --- /dev/null +++ b/test/sass/ruleset/11.sass @@ -0,0 +1,3 @@ +:root + --foo-bar: + content: 'foobar' diff --git a/test/sass/ruleset/test.coffee b/test/sass/ruleset/test.coffee index 40435bcb..90db9d73 100644 --- a/test/sass/ruleset/test.coffee +++ b/test/sass/ruleset/test.coffee @@ -11,6 +11,7 @@ describe 'sass/ruleset >>', -> it '8', -> this.shouldBeOk() it '9', -> this.shouldBeOk() it '10', -> this.shouldBeOk() + it '11', -> this.shouldBeOk() it 'color.ident.0', -> this.shouldBeOk() it 'color.ident.1', -> this.shouldBeOk() diff --git a/test/scss/atrule/14.json b/test/scss/atrule/14.json new file mode 100644 index 00000000..3d6a60aa --- /dev/null +++ b/test/scss/atrule/14.json @@ -0,0 +1,81 @@ +{ + "type": "atrule", + "content": [ + { + "type": "atkeyword", + "content": [ + { + "type": "ident", + "content": "apply", + "syntax": "scss", + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 6 + } + } + ], + "syntax": "scss", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 6 + } + }, + { + "type": "space", + "content": " ", + "syntax": "scss", + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 1, + "column": 7 + } + }, + { + "type": "customProperty", + "content": [ + { + "type": "ident", + "content": "custom-property", + "syntax": "scss", + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 1, + "column": 24 + } + } + ], + "syntax": "scss", + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 24 + } + } + ], + "syntax": "scss", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 24 + } +} diff --git a/test/scss/atrule/14.scss b/test/scss/atrule/14.scss new file mode 100644 index 00000000..ee381833 --- /dev/null +++ b/test/scss/atrule/14.scss @@ -0,0 +1 @@ +@apply --custom-property diff --git a/test/scss/atrule/test.coffee b/test/scss/atrule/test.coffee index 1bf76a95..54da4854 100644 --- a/test/scss/atrule/test.coffee +++ b/test/scss/atrule/test.coffee @@ -14,6 +14,7 @@ describe 'scss/atrule >>', -> it '11', -> this.shouldBeOk() it '12', -> this.shouldBeOk() it '13', -> this.shouldBeOk() + it '14', -> this.shouldBeOk() it 'c.0', -> this.shouldBeOk() it 'c.1', -> this.shouldBeOk() diff --git a/test/scss/ruleset/9.json b/test/scss/ruleset/9.json new file mode 100644 index 00000000..b8419abb --- /dev/null +++ b/test/scss/ruleset/9.json @@ -0,0 +1,336 @@ +{ + "type": "ruleset", + "content": [ + { + "type": "selector", + "content": [ + { + "type": "pseudoClass", + "content": [ + { + "type": "ident", + "content": "root", + "syntax": "scss", + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 5 + } + } + ], + "syntax": "scss", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + } + ], + "syntax": "scss", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 5 + } + }, + { + "type": "space", + "content": " ", + "syntax": "scss", + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 6 + } + }, + { + "type": "block", + "content": [ + { + "type": "space", + "content": "\n ", + "syntax": "scss", + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 2, + "column": 2 + } + }, + { + "type": "declaration", + "content": [ + { + "type": "customProperty", + "content": [ + { + "type": "ident", + "content": "foo-bar", + "syntax": "scss", + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 11 + } + } + ], + "syntax": "scss", + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 2, + "column": 11 + } + }, + { + "type": "propertyDelimiter", + "content": ":", + "syntax": "scss", + "start": { + "line": 2, + "column": 12 + }, + "end": { + "line": 2, + "column": 12 + } + }, + { + "type": "space", + "content": " ", + "syntax": "scss", + "start": { + "line": 2, + "column": 13 + }, + "end": { + "line": 2, + "column": 13 + } + }, + { + "type": "value", + "content": [ + { + "type": "block", + "content": [ + { + "type": "space", + "content": "\n ", + "syntax": "scss", + "start": { + "line": 2, + "column": 15 + }, + "end": { + "line": 3, + "column": 4 + } + }, + { + "type": "declaration", + "content": [ + { + "type": "property", + "content": [ + { + "type": "ident", + "content": "content", + "syntax": "scss", + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 11 + } + } + ], + "syntax": "scss", + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 11 + } + }, + { + "type": "propertyDelimiter", + "content": ":", + "syntax": "scss", + "start": { + "line": 3, + "column": 12 + }, + "end": { + "line": 3, + "column": 12 + } + }, + { + "type": "space", + "content": " ", + "syntax": "scss", + "start": { + "line": 3, + "column": 13 + }, + "end": { + "line": 3, + "column": 13 + } + }, + { + "type": "value", + "content": [ + { + "type": "string", + "content": "'foobar'", + "syntax": "scss", + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 21 + } + } + ], + "syntax": "scss", + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 21 + } + } + ], + "syntax": "scss", + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 21 + } + }, + { + "type": "declarationDelimiter", + "content": ";", + "syntax": "scss", + "start": { + "line": 3, + "column": 22 + }, + "end": { + "line": 3, + "column": 22 + } + }, + { + "type": "space", + "content": "\n ", + "syntax": "scss", + "start": { + "line": 3, + "column": 23 + }, + "end": { + "line": 4, + "column": 2 + } + } + ], + "syntax": "scss", + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 4, + "column": 3 + } + } + ], + "syntax": "scss", + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 4, + "column": 3 + } + } + ], + "syntax": "scss", + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 4, + "column": 3 + } + }, + { + "type": "space", + "content": "\n", + "syntax": "scss", + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 4 + } + } + ], + "syntax": "scss", + "start": { + "line": 1, + "column": 7 + }, + "end": { + "line": 5, + "column": 1 + } + } + ], + "syntax": "scss", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 5, + "column": 1 + } +} diff --git a/test/scss/ruleset/9.scss b/test/scss/ruleset/9.scss new file mode 100644 index 00000000..ed19f380 --- /dev/null +++ b/test/scss/ruleset/9.scss @@ -0,0 +1,5 @@ +:root { + --foo-bar: { + content: 'foobar'; + } +} diff --git a/test/scss/ruleset/test.coffee b/test/scss/ruleset/test.coffee index 18fe9731..3dd77e45 100644 --- a/test/scss/ruleset/test.coffee +++ b/test/scss/ruleset/test.coffee @@ -9,6 +9,7 @@ describe 'scss/ruleset >>', -> it '6', -> this.shouldBeOk() it '7', -> this.shouldBeOk() it '8', -> this.shouldBeOk() + it '9', -> this.shouldBeOk() it 'c.0', -> this.shouldBeOk() it 'c.1', -> this.shouldBeOk()