Skip to content

Commit

Permalink
support multiple variables in @each (for microsoft/vscode#1758)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli committed Jan 23, 2017
1 parent 2d79855 commit 505085c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/parser/scssParser.ts
Expand Up @@ -340,6 +340,11 @@ export class SCSSParser extends cssParser.Parser {
if (!node.setVariable(this._parseVariable())) {
return this.finish(node, ParseError.VariableNameExpected, [TokenType.CurlyR]);
}
while (this.accept(TokenType.Comma)) {
if (!node.setVariable(this._parseVariable())) {
return this.finish(node, ParseError.VariableNameExpected, [TokenType.CurlyR]);
}
}
if (!this.accept(TokenType.Ident, 'in')) {
return this.finish(node, SCSSParseError.InExpected, [TokenType.CurlyR]);
}
Expand Down
2 changes: 2 additions & 0 deletions src/test/scss/parser.test.ts
Expand Up @@ -231,9 +231,11 @@ suite('SCSS - Parser', () => {
let parser = new SCSSParser();
assertNode('@each $i in 1, 2, 3 { }', parser, parser._parseRuleSetDeclaration.bind(parser));
assertNode('@each $i in 1 2 3 { }', parser, parser._parseRuleSetDeclaration.bind(parser));
assertNode('@each $animal, $color, $cursor in (puma, black, default), (egret, white, move) {}', parser, parser._parseRuleSetDeclaration.bind(parser));
assertError('@each i in 4 {}', parser, parser._parseRuleSetDeclaration.bind(parser), ParseError.VariableNameExpected);
assertError('@each $i from 4 {}', parser, parser._parseRuleSetDeclaration.bind(parser), SCSSParseError.InExpected);
assertError('@each $i in {}', parser, parser._parseRuleSetDeclaration.bind(parser), ParseError.ExpressionExpected);
assertError('@each $animal, in (1, 1, 1), (2, 2, 2) {}', parser, parser._parseRuleSetDeclaration.bind(parser), ParseError.VariableNameExpected);
});

test('@while', function () {
Expand Down

0 comments on commit 505085c

Please sign in to comment.