Skip to content

Commit 2dc31d9

Browse files
feat(css/ast): Add / to the delimiters (#3402)
1 parent b28b636 commit 2dc31d9

File tree

12 files changed

+1031
-402
lines changed

12 files changed

+1031
-402
lines changed

crates/swc_css_ast/src/value.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ pub enum Value {
5555
pub enum DelimiterValue {
5656
/// `,`
5757
Comma,
58+
/// `/`
59+
Solidus,
5860
}
5961

6062
#[ast_node("Delimiter")]

crates/swc_css_codegen/tests/fixture/packages/bootstrap_5_1_3/input.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/swc_css_codegen/tests/fixture/packages/bootstrap_5_1_3/output.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,6 +2409,7 @@ width: 1em;
24092409
height: 1em;
24102410
padding: 0.25em 0.25em;
24112411
color: #000;
2412+
background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23000'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e") center / 1em auto no-repeat;
24122413
border: 0;
24132414
border-radius: 0.25rem;
24142415
opacity: 0.5}

crates/swc_css_codegen/tests/fixture/packages/bootstrap_5_1_3/output.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/swc_css_parser/src/parser/value/mod.rs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,19 @@ where
3939

4040
if !eat!(self, " ")
4141
&& !is_one_of!(
42-
self, ",", "function", "ident", "percent", "str", "#", "url", "[", "{", "("
42+
self,
43+
",",
44+
"/",
45+
"function",
46+
"ident",
47+
"dimension",
48+
"percent",
49+
"str",
50+
"#",
51+
"url",
52+
"[",
53+
"{",
54+
"("
4355
)
4456
{
4557
if self.ctx.recover_from_property_value
@@ -232,6 +244,15 @@ where
232244
}));
233245
}
234246

247+
tok!("/") => {
248+
bump!(self);
249+
250+
return Ok(Value::Delimiter(Delimiter {
251+
span: span!(self, span.lo),
252+
value: DelimiterValue::Solidus,
253+
}));
254+
}
255+
235256
tok!("str") => return Ok(Value::Str(self.parse()?)),
236257

237258
tok!("num") => return self.parse_numeric_value(),

crates/swc_css_parser/tests/fixture/declaration/input.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ div {
66
prop: fn(value);
77
prop: fn(value)fn(value);
88
prop: value, value;
9+
prop: value ,value;
910
prop: value,value;
11+
prop: value , value;
1012
prop: 100%100%;
1113
prop: "string""string";
1214
prop: #ccc#ccc;
1315
prop: url(value)url(value);
1416
prop: (value)(value);
1517
prop: {value}{value};
1618
prop: [value][value];
19+
prop: center/1em;
20+
prop: center/ 1em;
21+
prop: center /1em;
22+
prop: center / 1em;
1723
}

0 commit comments

Comments
 (0)