Skip to content

Commit

Permalink
Fix serializing :host and ::slotted
Browse files Browse the repository at this point in the history
Fixes #409
  • Loading branch information
devongovett committed Feb 12, 2023
1 parent 31fc453 commit 482fc40
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5734,6 +5734,8 @@ mod tests {
minify_test("a:is(:first-child) { color: yellow }", "a:first-child{color:#ff0}");
minify_test("a:is(:has(.foo)) { color: yellow }", "a:has(.foo){color:#ff0}");
minify_test("a:is(:is(.foo)) { color: yellow }", "a.foo{color:#ff0}");
minify_test(":host(:hover) {color: red}", ":host(:hover){color:red}");
minify_test("::slotted(:hover) {color: red}", "::slotted(:hover){color:red}");
}

#[test]
Expand Down
14 changes: 14 additions & 0 deletions src/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1324,6 +1324,20 @@ where
dest.write_char('#')?;
dest.write_ident(&id.0)
}
Component::Host(selector) => {
dest.write_str(":host")?;
if let Some(ref selector) = *selector {
dest.write_char('(')?;
selector.to_css(dest)?;
dest.write_char(')')?;
}
Ok(())
}
Component::Slotted(ref selector) => {
dest.write_str("::slotted(")?;
selector.to_css(dest)?;
dest.write_char(')')
}
_ => {
cssparser::ToCss::to_css(component, dest)?;
Ok(())
Expand Down

0 comments on commit 482fc40

Please sign in to comment.