@@ -6,18 +6,20 @@ import 'package:js/js.dart';
6
6
7
7
import '../../value.dart' ;
8
8
import '../reflection.dart' ;
9
+ import '../utils.dart' ;
9
10
10
11
/// The JavaScript `SassColor` class.
11
12
final JSClass colorClass = () {
12
13
var jsClass = createJSClass ('sass.SassColor' , (Object self, _Channels color) {
13
14
if (color.red != null ) {
14
- return SassColor .rgb (color.red! , color.green! , color.blue! , color.alpha);
15
+ return SassColor .rgb (color.red! , color.green! , color.blue! ,
16
+ _handleUndefinedAlpha (color.alpha));
15
17
} else if (color.saturation != null ) {
16
- return SassColor .hsl (
17
- color.hue ! , color.saturation ! , color.lightness ! , color. alpha);
18
+ return SassColor .hsl (color.hue ! , color.saturation ! , color.lightness ! ,
19
+ _handleUndefinedAlpha ( color.alpha) );
18
20
} else {
19
- return SassColor .hwb (
20
- color.hue ! , color.whiteness ! , color.blackness ! , color. alpha);
21
+ return SassColor .hwb (color.hue ! , color.whiteness ! , color.blackness ! ,
22
+ _handleUndefinedAlpha ( color.alpha) );
21
23
}
22
24
});
23
25
@@ -70,6 +72,12 @@ final JSClass colorClass = () {
70
72
return jsClass;
71
73
}();
72
74
75
+ /// Converts an undefined [alpha] to 1.
76
+ ///
77
+ /// This ensures that an explicitly null alpha will be treated as a missing
78
+ /// component.
79
+ num ? _handleUndefinedAlpha (num ? alpha) => isUndefined (alpha) ? 1 : alpha;
80
+
73
81
@JS ()
74
82
@anonymous
75
83
class _Channels {
0 commit comments