This commit is contained in:
ConnorSkees 2020-05-16 18:38:37 -04:00
parent 1fb6822259
commit d4f67b5ed9
3 changed files with 18 additions and 20 deletions

View File

@ -135,8 +135,8 @@ impl CallArgs {
super_selector: &Selector, super_selector: &Selector,
) -> Option<SassResult<Spanned<Value>>> { ) -> Option<SassResult<Spanned<Value>>> {
match self.get_named(name, scope, super_selector) { match self.get_named(name, scope, super_selector) {
Some(v) => return Some(v), Some(v) => Some(v),
None => return self.get_positional(position, scope, super_selector), None => self.get_positional(position, scope, super_selector),
} }
} }

View File

@ -74,12 +74,12 @@ impl Mixin {
)?; )?;
break; break;
} }
let val = match args.get(idx, arg.name.clone(), &scope, super_selector) { let val = match args.get(idx, arg.name.clone(), scope, super_selector) {
Some(v) => v?, Some(v) => v?,
None => match arg.default.as_mut() { None => match arg.default.as_mut() {
Some(v) => Value::from_tokens( Some(v) => Value::from_tokens(
&mut std::mem::take(v).into_iter().peekmore(), &mut std::mem::take(v).into_iter().peekmore(),
&scope, scope,
super_selector, super_selector,
)?, )?,
None => { None => {

View File

@ -482,28 +482,26 @@ impl Color {
/// Get the proper representation from RGBA values /// Get the proper representation from RGBA values
fn repr(red: &Number, green: &Number, blue: &Number, alpha: &Number) -> String { fn repr(red: &Number, green: &Number, blue: &Number, alpha: &Number) -> String {
macro_rules! into_u8 { fn into_u8(channel: &Number) -> u8 {
($channel:ident) => { if channel > &Number::from(255) {
let $channel = if $channel > &Number::from(255) {
255_u8 255_u8
} else if $channel.is_negative() { } else if channel.is_negative() {
0_u8 0_u8
} else { } else {
$channel.clone().round().to_integer().to_u8().unwrap() channel.round().to_integer().to_u8().unwrap()
}; }
};
} }
into_u8!(red); let red_u8 = into_u8(red);
into_u8!(green); let green_u8 = into_u8(green);
into_u8!(blue); let blue_u8 = into_u8(blue);
if alpha < &Number::one() { if alpha < &Number::one() {
format!("rgba({}, {}, {}, {})", red, green, blue, alpha) format!("rgba({}, {}, {}, {})", red_u8, green_u8, blue_u8, alpha)
} else if let Some(c) = NAMED_COLORS.get_by_right(&[red, green, blue, 0xFF]) { } else if let Some(c) = NAMED_COLORS.get_by_right(&[red_u8, green_u8, blue_u8, 0xFF]) {
(*c).to_string() (*c).to_string()
} else { } else {
format!("#{:0>2x}{:0>2x}{:0>2x}", red, green, blue) format!("#{:0>2x}{:0>2x}{:0>2x}", red_u8, green_u8, blue_u8)
} }
} }