refactor lowercasing of idents
avoid creating more strings than necessary
This commit is contained in:
parent
0aed492123
commit
1d518efeaf
@ -503,7 +503,9 @@ impl Value {
|
||||
) -> SassResult<IntermediateValue> {
|
||||
let Spanned { node: mut s, span } = eat_ident(toks, scope, super_selector)?;
|
||||
|
||||
if s == "progid" && toks.peek().is_some() && toks.peek().unwrap().kind == ':' {
|
||||
let lower = s.to_ascii_lowercase();
|
||||
|
||||
if lower == "progid" && toks.peek().is_some() && toks.peek().unwrap().kind == ':' {
|
||||
toks.next();
|
||||
s.push(':');
|
||||
s.push_str(&eat_progid(toks, scope, super_selector)?);
|
||||
@ -528,7 +530,7 @@ impl Value {
|
||||
}))
|
||||
}
|
||||
None => {
|
||||
match s.to_ascii_lowercase().as_str() {
|
||||
match lower.as_str() {
|
||||
"calc" | "element" | "expression" => {
|
||||
s.push_str(&eat_calc_args(toks, scope, super_selector)?)
|
||||
}
|
||||
@ -557,14 +559,14 @@ impl Value {
|
||||
));
|
||||
}
|
||||
|
||||
if let Some(c) = NAMED_COLORS.get_by_left(&s.as_str()) {
|
||||
if let Some(c) = NAMED_COLORS.get_by_left(&lower.as_str()) {
|
||||
return Ok(IntermediateValue::Value(Spanned {
|
||||
node: Value::Color(Box::new(Color::new(c[0], c[1], c[2], c[3], s))),
|
||||
span,
|
||||
}));
|
||||
}
|
||||
|
||||
Ok(match s.to_ascii_lowercase().as_str() {
|
||||
Ok(match lower.as_str() {
|
||||
"true" => IntermediateValue::Value(Value::True.span(span)),
|
||||
"false" => IntermediateValue::Value(Value::False.span(span)),
|
||||
"null" => IntermediateValue::Value(Value::Null.span(span)),
|
||||
|
@ -4,6 +4,11 @@
|
||||
mod macros;
|
||||
|
||||
test!(preserves_named_color_case, "a {\n color: OrAnGe;\n}\n");
|
||||
test!(
|
||||
named_color_casing_is_color,
|
||||
"a {\n color: hue(RED);\n}\n",
|
||||
"a {\n color: 0deg;\n}\n"
|
||||
);
|
||||
test!(preserves_hex_color_case, "a {\n color: #FfFfFf;\n}\n");
|
||||
test!(
|
||||
preserves_hex_8_val_10000000,
|
||||
|
Loading…
x
Reference in New Issue
Block a user