Skip to content

Commit 21819c3

Browse files
committed
Add support for @for rules
1 parent b60577e commit 21819c3

File tree

7 files changed

+688
-1
lines changed

7 files changed

+688
-1
lines changed

pkg/sass-parser/lib/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export {
4444
ErrorRuleProps,
4545
ErrorRuleRaws,
4646
} from './src/statement/error-rule';
47+
export {ForRule, ForRuleProps, ForRuleRaws} from './src/statement/for-rule';
4748
export {
4849
GenericAtRule,
4950
GenericAtRuleProps,

pkg/sass-parser/lib/src/sass-internal.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ declare namespace SassInternal {
9494
readonly isOptional: boolean;
9595
}
9696

97+
class ForRule extends ParentStatement<Statement[]> {
98+
readonly variable: string;
99+
readonly from: Expression;
100+
readonly to: Expression;
101+
readonly isExclusive: boolean;
102+
}
103+
97104
class Stylesheet extends ParentStatement<Statement[]> {}
98105

99106
class StyleRule extends ParentStatement<Statement[]> {
@@ -135,6 +142,7 @@ export type DebugRule = SassInternal.DebugRule;
135142
export type EachRule = SassInternal.EachRule;
136143
export type ErrorRule = SassInternal.ErrorRule;
137144
export type ExtendRule = SassInternal.ExtendRule;
145+
export type ForRule = SassInternal.ForRule;
138146
export type Stylesheet = SassInternal.Stylesheet;
139147
export type StyleRule = SassInternal.StyleRule;
140148
export type Interpolation = SassInternal.Interpolation;
@@ -149,6 +157,7 @@ export interface StatementVisitorObject<T> {
149157
visitEachRule(node: EachRule): T;
150158
visitErrorRule(node: ErrorRule): T;
151159
visitExtendRule(node: ExtendRule): T;
160+
visitForRule(node: ForRule): T;
152161
visitStyleRule(node: StyleRule): T;
153162
}
154163

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`an @for rule toJSON 1`] = `
4+
{
5+
"fromExpression": <bar>,
6+
"inputs": [
7+
{
8+
"css": "@for $foo from bar to baz {}",
9+
"hasBOM": false,
10+
"id": "<input css _____>",
11+
},
12+
],
13+
"name": "for",
14+
"nodes": [],
15+
"params": "$foo from bar to baz",
16+
"raws": {},
17+
"sassType": "for-rule",
18+
"source": <1:1-1:29 in 0>,
19+
"to": "to",
20+
"toExpression": <baz>,
21+
"type": "atrule",
22+
"variable": "foo",
23+
}
24+
`;

0 commit comments

Comments
 (0)