Fix lost combinator before global (#30771)

This commit is contained in:
Maia Teegarden 2021-11-03 02:00:49 -07:00 committed by GitHub
parent 2004d49198
commit 5f72810dd6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 1 deletions

View file

@ -138,7 +138,7 @@ impl VisitMut for Namespacer {
handler handler
.struct_span_err( .struct_span_err(
selector.span, selector.span,
"Failed to parse tokens inside one off global selector", "Failed to transform one off global selector",
) )
.emit() .emit()
}); });
@ -187,6 +187,16 @@ impl Namespacer {
.cloned() .cloned()
.collect::<Vec<_>>(); .collect::<Vec<_>>();
if v.is_empty() {
bail!("Failed to transform one off global selector");
}
if node.combinator.is_some() && v[0].combinator.is_some() {
bail!("Failed to transform one off global selector");
} else if node.combinator.is_some() {
v[0].combinator = node.combinator;
}
v.iter_mut().for_each(|sel| { v.iter_mut().for_each(|sel| {
if i < node.subclass_selectors.len() { if i < node.subclass_selectors.len() {
sel.subclass_selectors sel.subclass_selectors

View file

@ -0,0 +1,10 @@
const Test = () => (
<div>
<span>test</span>
<style jsx>{`
div > :global(span) {
color: red;
}
`}</style>
</div>
)

View file

@ -0,0 +1,9 @@
import _JSXStyle from "styled-jsx/style";
const Test = ()=><div className={"jsx-5a206f122d1cb32e"}>
<span className={"jsx-5a206f122d1cb32e"}>test</span>
<_JSXStyle id={"5a206f122d1cb32e"}>{"div.jsx-5a206f122d1cb32e >span {color:red}"}</_JSXStyle>
</div>
;