Skip to content

Commit

Permalink
Add support for @for rules
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Sep 4, 2024
1 parent b60577e commit 21819c3
Show file tree
Hide file tree
Showing 7 changed files with 688 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/sass-parser/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export {
ErrorRuleProps,
ErrorRuleRaws,
} from './src/statement/error-rule';
export {ForRule, ForRuleProps, ForRuleRaws} from './src/statement/for-rule';
export {
GenericAtRule,
GenericAtRuleProps,
Expand Down
9 changes: 9 additions & 0 deletions pkg/sass-parser/lib/src/sass-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ declare namespace SassInternal {
readonly isOptional: boolean;
}

class ForRule extends ParentStatement<Statement[]> {
readonly variable: string;
readonly from: Expression;
readonly to: Expression;
readonly isExclusive: boolean;
}

class Stylesheet extends ParentStatement<Statement[]> {}

class StyleRule extends ParentStatement<Statement[]> {
Expand Down Expand Up @@ -135,6 +142,7 @@ export type DebugRule = SassInternal.DebugRule;
export type EachRule = SassInternal.EachRule;
export type ErrorRule = SassInternal.ErrorRule;
export type ExtendRule = SassInternal.ExtendRule;
export type ForRule = SassInternal.ForRule;
export type Stylesheet = SassInternal.Stylesheet;
export type StyleRule = SassInternal.StyleRule;
export type Interpolation = SassInternal.Interpolation;
Expand All @@ -149,6 +157,7 @@ export interface StatementVisitorObject<T> {
visitEachRule(node: EachRule): T;
visitErrorRule(node: ErrorRule): T;
visitExtendRule(node: ExtendRule): T;
visitForRule(node: ForRule): T;
visitStyleRule(node: StyleRule): T;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`an @for rule toJSON 1`] = `
{
"fromExpression": <bar>,
"inputs": [
{
"css": "@for $foo from bar to baz {}",
"hasBOM": false,
"id": "<input css _____>",
},
],
"name": "for",
"nodes": [],
"params": "$foo from bar to baz",
"raws": {},
"sassType": "for-rule",
"source": <1:1-1:29 in 0>,
"to": "to",
"toExpression": <baz>,
"type": "atrule",
"variable": "foo",
}
`;
Loading

0 comments on commit 21819c3

Please sign in to comment.