Skip to content

Commit

Permalink
fix layer and container in scss (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
aeschli authored Nov 13, 2023
1 parent f55163f commit 5d30238
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/parser/cssParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -950,11 +950,10 @@ export class Parser {

public _parseLayerName(): nodes.Node | null {
// <layer-name> = <ident> [ '.' <ident> ]*
if (!this.peek(TokenType.Ident)) {
const node = this.createNode(nodes.NodeType.LayerName);
if (!node.addChild(this._parseIdent()) ) {
return null;
}
const node = this.createNode(nodes.NodeType.LayerName);
node.addChild(this._parseIdent());
while (!this.hasWhitespace() && this.acceptDelim('.')) {
if (this.hasWhitespace() || !node.addChild(this._parseIdent())) {
return this.finish(node, ParseError.IdentifierExpected);
Expand Down
4 changes: 2 additions & 2 deletions src/parser/cssScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export enum TokenType {
Comment,
SingleLineComment,
EOF,
CustomToken,
ContainerQueryLength
ContainerQueryLength,
CustomToken // must be last token type
}

export interface IToken {
Expand Down
10 changes: 10 additions & 0 deletions src/test/scss/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,16 @@ suite('SCSS - Parser', () => {
assertNode('@import url("override.css") layer;', parser, parser._parseStylesheet.bind(parser));
});

test('@layer', function () {
const parser = new SCSSParser();
assertNode('@layer #{$layer} { }', parser, parser._parseLayer.bind(parser));
});

test('@container', function () {
const parser = new SCSSParser();
assertNode(`@container (min-width: #{$minWidth}) { .scss-interpolation { line-height: 10cqh; } }`, parser, parser._parseStylesheet.bind(parser));
});

test('@use', function () {
const parser = new SCSSParser();
assertNode('@use "test"', parser, parser._parseUse.bind(parser));
Expand Down

0 comments on commit 5d30238

Please sign in to comment.