proper error message for non-string to feature-exists

This commit is contained in:
ConnorSkees 2020-03-23 15:02:50 -04:00
parent b91683b02e
commit 0f310e9582

View File

@ -22,23 +22,26 @@ pub(crate) fn register(f: &mut HashMap<String, Builtin>) {
"feature-exists".to_owned(), "feature-exists".to_owned(),
Box::new(|args, _| { Box::new(|args, _| {
max_args!(args, 1); max_args!(args, 1);
match arg!(args, 0, "feature").unquote().to_string().as_str() { match arg!(args, 0, "feature") {
// A local variable will shadow a global variable unless Value::Ident(s, _) => match s.as_str() {
// `!global` is used. // A local variable will shadow a global variable unless
"global-variable-shadowing" => Ok(Value::False), // `!global` is used.
// the @extend rule will affect selectors nested in pseudo-classes "global-variable-shadowing" => Ok(Value::False),
// like :not() // the @extend rule will affect selectors nested in pseudo-classes
"extend-selector-pseudoclass" => Ok(Value::False), // like :not()
// Full support for unit arithmetic using units defined in the "extend-selector-pseudoclass" => Ok(Value::False),
// [Values and Units Level 3][] spec. // Full support for unit arithmetic using units defined in the
"units-level-3" => Ok(Value::True), // [Values and Units Level 3][] spec.
// The Sass `@error` directive is supported. "units-level-3" => Ok(Value::True),
"at-error" => Ok(Value::True), // The Sass `@error` directive is supported.
// The "Custom Properties Level 1" spec is supported. This means "at-error" => Ok(Value::True),
// that custom properties are parsed statically, with only // The "Custom Properties Level 1" spec is supported. This means
// interpolation treated as SassScript. // that custom properties are parsed statically, with only
"custom-property" => Ok(Value::False), // interpolation treated as SassScript.
_ => Ok(Value::False), "custom-property" => Ok(Value::False),
_ => Ok(Value::False),
},
v => Err(format!("$feature: {} is not a string.", v).into()),
} }
}), }),
); );