Skip to content

Commit 482fc40

Browse files
committed
Fix serializing :host and ::slotted
Fixes parcel-bundler#409
1 parent 31fc453 commit 482fc40

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5734,6 +5734,8 @@ mod tests {
57345734
minify_test("a:is(:first-child) { color: yellow }", "a:first-child{color:#ff0}");
57355735
minify_test("a:is(:has(.foo)) { color: yellow }", "a:has(.foo){color:#ff0}");
57365736
minify_test("a:is(:is(.foo)) { color: yellow }", "a.foo{color:#ff0}");
5737+
minify_test(":host(:hover) {color: red}", ":host(:hover){color:red}");
5738+
minify_test("::slotted(:hover) {color: red}", "::slotted(:hover){color:red}");
57375739
}
57385740

57395741
#[test]

src/selector.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1324,6 +1324,20 @@ where
13241324
dest.write_char('#')?;
13251325
dest.write_ident(&id.0)
13261326
}
1327+
Component::Host(selector) => {
1328+
dest.write_str(":host")?;
1329+
if let Some(ref selector) = *selector {
1330+
dest.write_char('(')?;
1331+
selector.to_css(dest)?;
1332+
dest.write_char(')')?;
1333+
}
1334+
Ok(())
1335+
}
1336+
Component::Slotted(ref selector) => {
1337+
dest.write_str("::slotted(")?;
1338+
selector.to_css(dest)?;
1339+
dest.write_char(')')
1340+
}
13271341
_ => {
13281342
cssparser::ToCss::to_css(component, dest)?;
13291343
Ok(())

0 commit comments

Comments
 (0)