From d25744eb3508187f4658e0d62032ba693228ef0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Fri, 11 Oct 2024 19:42:20 -0700 Subject: [PATCH] Support missing channels across the embedded protocol (#246) --- lib/sass/compiler/host/protofier.rb | 9 +++++---- spec/sass_proto_spec.rb | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/sass/compiler/host/protofier.rb b/lib/sass/compiler/host/protofier.rb index 3140f211..fcf487c9 100644 --- a/lib/sass/compiler/host/protofier.rb +++ b/lib/sass/compiler/host/protofier.rb @@ -112,13 +112,14 @@ def from_proto(proto) when :number Number.from_proto(obj) when :color + obj.to_s # TODO: https://github.com/protocolbuffers/protobuf/issues/18807 Sass::Value::Color.send( :for_space, obj.space, - obj.channel1, - obj.channel2, - obj.channel3, - obj.alpha + obj.has_channel1? ? obj.channel1 : nil, + obj.has_channel2? ? obj.channel2 : nil, + obj.has_channel3? ? obj.channel3 : nil, + obj.has_alpha? ? obj.alpha : nil ) when :argument_list Sass::Value::ArgumentList.new( diff --git a/spec/sass_proto_spec.rb b/spec/sass_proto_spec.rb index 2f836b00..a2c43e19 100644 --- a/spec/sass_proto_spec.rb +++ b/spec/sass_proto_spec.rb @@ -63,9 +63,9 @@ def remote_eq(lhs, rhs) ]) ]), __LINE__ => Sass::Value::Calculation.clamp(Sass::Value::String.new('var(--clamp)', quoted: false)), - __LINE__ => Sass::Value::Color.new(red: 0, green: 0, blue: 0, alpha: 1), - __LINE__ => Sass::Value::Color.new(hue: 0, saturation: 0, lightness: 0, alpha: 1), - __LINE__ => Sass::Value::Color.new(hue: 0, whiteness: 0, blackness: 0, alpha: 1), + __LINE__ => Sass::Value::Color.new(red: 0.1, green: 0.2, blue: nil, alpha: 1, space: 'rgb'), + __LINE__ => Sass::Value::Color.new(hue: 0.4, saturation: nil, lightness: 0.6, alpha: 1, space: 'hsl'), + __LINE__ => Sass::Value::Color.new(hue: nil, whiteness: 0.8, blackness: 0.9, alpha: 1, space: 'hwb'), __LINE__ => Sass::Value::List.new, __LINE__ => Sass::Value::List.new([Sass::Value::String.new('a')]), __LINE__ => Sass::Value::List.new([Sass::Value::String.new('a')], separator: ','),