Skip to content

Commit 3110a4c

Browse files
authored
Fix deprotofy SassCalculation.clamp (#241)
1 parent 2b1f4ec commit 3110a4c

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

lib/src/protofier.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -380,15 +380,22 @@ export class Protofier {
380380
this.deprotofyCalculationValue(calculation.arguments[0])
381381
);
382382
case 'clamp':
383-
if (calculation.arguments.length !== 3) {
383+
if (
384+
calculation.arguments.length === 0 ||
385+
calculation.arguments.length > 3
386+
) {
384387
throw utils.compilerError(
385-
'Value.Calculation.arguments must have exactly 3 arguments for clamp().'
388+
'Value.Calculation.arguments must have 1 to 3 arguments for clamp().'
386389
);
387390
}
388391
return SassCalculation.clamp(
389392
this.deprotofyCalculationValue(calculation.arguments[0]),
390-
this.deprotofyCalculationValue(calculation.arguments[1]),
391-
this.deprotofyCalculationValue(calculation.arguments[2])
393+
calculation.arguments.length > 1
394+
? this.deprotofyCalculationValue(calculation.arguments[1])
395+
: undefined,
396+
calculation.arguments.length > 2
397+
? this.deprotofyCalculationValue(calculation.arguments[2])
398+
: undefined
392399
);
393400
case 'min':
394401
if (calculation.arguments.length === 0) {

0 commit comments

Comments
 (0)