@@ -448,11 +448,8 @@ final module = BuiltInModule("color", functions: <Callable>[
448
448
r"$color, $channel" ,
449
449
(arguments) => SassBoolean (arguments[0 ]
450
450
.assertColor ("color" )
451
- .isChannelMissing (
452
- (arguments[1 ].assertString ("channel" )..assertQuoted ("channel" ))
453
- .text,
454
- colorName: "color" ,
455
- channelName: "channel" ))),
451
+ .isChannelMissing (_channelName (arguments[1 ]),
452
+ colorName: "color" , channelName: "channel" ))),
456
453
457
454
_function (
458
455
"is-in-gamut" ,
@@ -475,7 +472,7 @@ final module = BuiltInModule("color", functions: <Callable>[
475
472
476
473
_function ("channel" , r"$color, $channel, $space: null" , (arguments) {
477
474
var color = _colorInSpace (arguments[0 ], arguments[2 ]);
478
- var channelName = arguments[1 ]. assertString ( "channel" ).text. toLowerCase ( );
475
+ var channelName = _channelName ( arguments[1 ]);
479
476
if (channelName == "alpha" ) return SassNumber (color.alpha);
480
477
481
478
var channelIndex = color.space.channels
@@ -511,10 +508,8 @@ final module = BuiltInModule("color", functions: <Callable>[
511
508
"is-powerless" ,
512
509
r"$color, $channel, $space: null" ,
513
510
(arguments) => SassBoolean (_colorInSpace (arguments[0 ], arguments[2 ])
514
- .isChannelPowerless (
515
- arguments[1 ].assertString ("channel" ).text.toLowerCase (),
516
- colorName: "color" ,
517
- channelName: "channel" ))),
511
+ .isChannelPowerless (_channelName (arguments[1 ]),
512
+ colorName: "color" , channelName: "channel" ))),
518
513
519
514
_complement,
520
515
@@ -1510,6 +1505,12 @@ String _suggestScaleAndAdjust(
1510
1505
return suggestion + "color.adjust(\$ color, \$ $channelName : $difference )" ;
1511
1506
}
1512
1507
1508
+ /// Asserts that `value` is an unquoted string and throws an error if it's not.
1509
+ ///
1510
+ /// Assumes that `value` comes from a parameter named `$channel` .
1511
+ String _channelName (Value value) =>
1512
+ (value.assertString ("channel" )..assertQuoted ("channel" )).text.toLowerCase ();
1513
+
1513
1514
/// Like [BuiltInCallable.function] , but always sets the URL to
1514
1515
/// `sass:color` .
1515
1516
BuiltInCallable _function (
0 commit comments