simplify variable checks

This commit is contained in:
ConnorSkees 2020-04-24 20:13:22 -04:00
parent 2fb64934d7
commit aea4235c9b

View File

@ -326,7 +326,7 @@ impl<'a> StyleSheetParser<'a> {
}
let VariableDecl { val, default, .. } =
eat_variable_value(&mut self.lexer, &Scope::new(), &Selector::new())?;
if (default && !global_var_exists(&name)) || !default {
if !(default && global_var_exists(&name)) {
insert_global_var(&name.node, val)?;
}
}
@ -635,7 +635,7 @@ pub(crate) fn eat_expr<I: Iterator<Item = Token>>(
insert_global_var(&name.node, val.clone())?;
}
let var_exists = scope.var_exists(&name.node);
if (default && !var_exists) || !default {
if !(default && var_exists) {
return Ok(Some(Spanned {
node: Expr::VariableDecl(name.node, Box::new(val)),
span,