Skip to content

Commit ad741fa

Browse files
committed
Consistently include parameters PostCSS attributes in toJSON()
1 parent 0de6e24 commit ad741fa

File tree

9 files changed

+23
-5
lines changed

9 files changed

+23
-5
lines changed

pkg/sass-parser/lib/src/statement/__snapshots__/declaration.test.ts.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ exports[`a property declaration toJSON with expression and no nodes 1`] = `
1010
"id": "<input css _____>",
1111
},
1212
],
13+
"prop": "foo",
1314
"propInterpolation": <foo>,
1415
"raws": {},
1516
"sassType": "decl",
1617
"source": <1:4-1:12 in 0>,
1718
"type": "decl",
19+
"value": "bar",
1820
}
1921
`;
2022
@@ -31,11 +33,13 @@ exports[`a property declaration toJSON with expression and nodes 1`] = `
3133
"nodes": [
3234
<baz: bang>,
3335
],
36+
"prop": "foo",
3437
"propInterpolation": <foo>,
3538
"raws": {},
3639
"sassType": "decl",
3740
"source": <1:4-1:24 in 0>,
3841
"type": "decl",
42+
"value": "bar",
3943
}
4044
`;
4145
@@ -51,10 +55,12 @@ exports[`a property declaration toJSON with no expression and nodes 1`] = `
5155
"nodes": [
5256
<baz: bang>,
5357
],
58+
"prop": "foo",
5459
"propInterpolation": <foo>,
5560
"raws": {},
5661
"sassType": "decl",
5762
"source": <1:4-1:20 in 0>,
5863
"type": "decl",
64+
"value": "",
5965
}
6066
`;

pkg/sass-parser/lib/src/statement/__snapshots__/function-rule.test.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ exports[`a @function rule toJSON 1`] = `
1313
"name": "function",
1414
"nodes": [],
1515
"parameters": <($bar)>,
16+
"params": "foo($bar)",
1617
"raws": {},
1718
"sassType": "function-rule",
1819
"source": <1:1-1:23 in 0>,

pkg/sass-parser/lib/src/statement/__snapshots__/mixin-rule.test.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ exports[`a @mixin rule toJSON 1`] = `
1313
"name": "mixin",
1414
"nodes": [],
1515
"parameters": <($bar)>,
16+
"params": "foo($bar)",
1617
"raws": {},
1718
"sassType": "mixin-rule",
1819
"source": <1:1-1:20 in 0>,

pkg/sass-parser/lib/src/statement/__snapshots__/variable-declaration.test.ts.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ exports[`a variable declaration toJSON 1`] = `
1313
},
1414
],
1515
"namespace": "baz",
16+
"prop": "baz.$foo",
1617
"raws": {},
1718
"sassType": "variable-declaration",
1819
"source": <1:1-1:16 in 0>,
1920
"type": "decl",
21+
"value": ""bar"",
2022
"variableName": "foo",
2123
}
2224
`;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export class Declaration
222222
toJSON(_?: string, inputs?: Map<postcss.Input, number>): object {
223223
return utils.toJSON(
224224
this,
225-
['propInterpolation', 'expression', 'nodes'],
225+
['prop', 'value', 'propInterpolation', 'expression', 'nodes'],
226226
inputs,
227227
);
228228
}

pkg/sass-parser/lib/src/statement/function-rule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class FunctionRule
134134
toJSON(_?: string, inputs?: Map<postcss.Input, number>): object {
135135
return utils.toJSON(
136136
this,
137-
['name', 'functionName', 'parameters', 'nodes'],
137+
['name', 'params', 'functionName', 'parameters', 'nodes'],
138138
inputs,
139139
);
140140
}

pkg/sass-parser/lib/src/statement/mixin-rule.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class MixinRule
134134
toJSON(_?: string, inputs?: Map<postcss.Input, number>): object {
135135
return utils.toJSON(
136136
this,
137-
['name', 'mixinName', 'parameters', 'nodes'],
137+
['name', 'params', 'mixinName', 'parameters', 'nodes'],
138138
inputs,
139139
);
140140
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export class SassComment
162162
/** @hidden */
163163
toJSON(_: string, inputs: Map<postcss.Input, number>): object;
164164
toJSON(_?: string, inputs?: Map<postcss.Input, number>): object {
165-
return utils.toJSON(this, ['text', 'text'], inputs);
165+
return utils.toJSON(this, ['text'], inputs);
166166
}
167167

168168
/** @hidden */

pkg/sass-parser/lib/src/statement/variable-declaration.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,15 @@ export class VariableDeclaration
207207
toJSON(_?: string, inputs?: Map<postcss.Input, number>): object {
208208
return utils.toJSON(
209209
this,
210-
['namespace', 'variableName', 'expression', 'guarded', 'global'],
210+
[
211+
'prop',
212+
'value',
213+
'namespace',
214+
'variableName',
215+
'expression',
216+
'guarded',
217+
'global',
218+
],
211219
inputs,
212220
);
213221
}

0 commit comments

Comments
 (0)