Skip to content

Commit 80af1c0

Browse files
committed
Code review
1 parent 8eb27a7 commit 80af1c0

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

pkg/sass-parser/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## 0.4.9
22

3-
* No user-visible changes.
3+
* Add support for parsing the `@if` and `@else` rules.
44

55
## 0.4.8
66

pkg/sass-parser/lib/src/statement/else-rule.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('an @else rule', () => {
1717
it('has no expression', () =>
1818
expect(node.elseCondition).toBeUndefined());
1919

20-
it('has matching params', () => expect(node.params).toBe(''));
20+
it('has empty params', () => expect(node.params).toBe(''));
2121

2222
it('has empty nodes', () => expect(node.nodes).toEqual([]));
2323
});
@@ -86,7 +86,7 @@ describe('an @else rule', () => {
8686
it('has an expression', () =>
8787
expect(node.elseCondition).toBeUndefined());
8888

89-
it('has matching params', () => expect(node.params).toBe(''));
89+
it('has empty params', () => expect(node.params).toBe(''));
9090

9191
it('has a child node', () => {
9292
expect(node.nodes).toHaveLength(1);

pkg/sass-parser/lib/src/statement/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,11 +208,14 @@ const visitor = sassInternal.createStatementVisitor<Statement | Statement[]>({
208208
visitFunctionRule: inner => new FunctionRule(undefined, inner),
209209
visitIfRule: inner => {
210210
const rules: Statement[] = [new IfRule(undefined, inner)];
211+
212+
// Skip `inner.clauses[0]` because it's already used by `new IfRule()`.
211213
for (let i = 1; i < inner.clauses.length; i++) {
212214
rules.push(new ElseRule(undefined, inner, inner.clauses[i]));
213215
}
214-
if (inner.lastClause)
216+
if (inner.lastClause) {
215217
rules.push(new ElseRule(undefined, inner, inner.lastClause));
218+
}
216219
return rules;
217220
},
218221
visitIncludeRule: inner => new IncludeRule(undefined, inner),

0 commit comments

Comments
 (0)