diff --git a/src/value/parse.rs b/src/value/parse.rs index df55e91..0fcb68a 100644 --- a/src/value/parse.rs +++ b/src/value/parse.rs @@ -204,6 +204,25 @@ fn eat_op>( span: right.span, }); } + Op::Div => { + devour_whitespace(iter); + let right = single_value(iter, scope, super_selector, op.span)?; + if let Some(left) = space_separated.pop() { + space_separated.push(Spanned { + node: Value::BinaryOp(Box::new(left.node), op.node, Box::new(right.node)), + span: left.span.merge(right.span), + }); + } else { + devour_whitespace(iter); + space_separated.push(Spanned { + node: Value::Ident( + format!("/{}", right.node.to_css_string(right.span)?), + QuoteKind::None, + ), + span: op.span.merge(right.span), + }); + } + } Op::Plus => { if let Some(left) = space_separated.pop() { devour_whitespace(iter); @@ -309,6 +328,17 @@ fn single_value>( devour_whitespace(iter); single_value(iter, scope, super_selector, span)? } + Op::Div => { + devour_whitespace(iter); + let val = single_value(iter, scope, super_selector, span)?; + Spanned { + node: Value::Ident( + format!("/{}", val.node.to_css_string(val.span)?), + QuoteKind::None, + ), + span: op.span.merge(val.span), + } + } _ => todo!(), }, IntermediateValue::Whitespace => unreachable!(), diff --git a/tests/division.rs b/tests/division.rs index 8c261d9..5db0aae 100644 --- a/tests/division.rs +++ b/tests/division.rs @@ -23,6 +23,11 @@ test!( "a {\n color: (35px / 7in);\n}\n", "a {\n color: 0.0520833333;\n}\n" ); +test!( + slash_after_comma, + "a {\n slash-after-comma: (1, / 2);\n}\n", + "a {\n slash-after-comma: 1, /2;\n}\n" +); // error!( // none_div_unit, // "a {\n color: (35 / 7%);\n}\n",