Unverified Commit 2874791a authored by Donny/강동윤's avatar Donny/강동윤 Committed by GitHub

Fix `styled-jsx`: Don't drop extra selectors (#29791)

Co-authored-by: 's avatarkdy1 <kdy1@users.noreply.github.com>
parent 99fed15b
...@@ -2098,9 +2098,9 @@ dependencies = [ ...@@ -2098,9 +2098,9 @@ dependencies = [
[[package]] [[package]]
name = "swc_ecma_transforms_testing" name = "swc_ecma_transforms_testing"
version = "0.38.0" version = "0.38.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "065e453a23c7465f1c049ad8888fdfc86dbd8bfd30e8b2707e71ed8a2d8a28e6" checksum = "7a53824975fbb8a412555802ee419e9f2ce24c9063b321ee98a9e574bc6125e3"
dependencies = [ dependencies = [
"ansi_term", "ansi_term",
"anyhow", "anyhow",
......
...@@ -180,10 +180,21 @@ impl Namespacer { ...@@ -180,10 +180,21 @@ impl Namespacer {
}); });
return match complex_selectors { return match complex_selectors {
Ok(complex_selectors) => Ok(complex_selectors[0].selectors[1..] Ok(complex_selectors) => {
.iter() let mut v = complex_selectors[0].selectors[1..]
.cloned() .iter()
.collect()), .cloned()
.collect::<Vec<_>>();
v.iter_mut().for_each(|sel| {
if i < node.subclass_selectors.len() {
sel.subclass_selectors
.extend(node.subclass_selectors[i + 1..].to_vec());
}
});
Ok(v)
}
Err(_) => bail!("Failed to transform one off global selector"), Err(_) => bail!("Failed to transform one off global selector"),
}; };
} else if pseudo_index.is_none() { } else if pseudo_index.is_none() {
......
function NavigationItem({
active,
className,
}) {
return (
<span className={cn({ active }, className, 'navigation-item')}>
<style jsx>{`
.navigation-item :global(a)::after {
content: attr(data-text);
content: attr(data-text) / '';
}
`}</style>
</span>
);
}
export default NavigationItem;
\ No newline at end of file
import _JSXStyle from "styled-jsx/style";
function NavigationItem({ active , className }) {
return <span className={"jsx-2342aae4628612c6" + " " + (cn({
active
}, className, "navigation-item") || "")}>
<_JSXStyle id={"2342aae4628612c6"}>{".navigation-item.jsx-2342aae4628612c6 a::after {content:attr(data-text);\ncontent: attr(data-text) / ''}"}</_JSXStyle>
</span>;
}
export default NavigationItem;
...@@ -11,6 +11,7 @@ export default class { ...@@ -11,6 +11,7 @@ export default class {
] ]
] ]
])}> ])}>
<p className={_JSXStyle.dynamic([ <p className={_JSXStyle.dynamic([
[ [
"4dca1c13af6604d3", "4dca1c13af6604d3",
...@@ -21,12 +22,14 @@ export default class { ...@@ -21,12 +22,14 @@ export default class {
] ]
] ]
])}>test</p> ])}>test</p>
<_JSXStyle id={"4dca1c13af6604d3"} dynamic={[ <_JSXStyle id={"4dca1c13af6604d3"} dynamic={[
a[b], a[b],
-1 * (c || 0), -1 * (c || 0),
d d
]}>{`.a .b.__jsx-style-dynamic-selector {a:${a[b]}px!important; ]}>{`.a:hover .b.__jsx-style-dynamic-selector {a:${a[b]}px!important;
b:translate3d(0, ${-1 * (c || 0)}px, -${d}px) scale(1)!important}`}</_JSXStyle> b:translate3d(0, ${-1 * (c || 0)}px, -${d}px) scale(1)!important}`}</_JSXStyle>
</div>; </div>;
} }
} };
\ No newline at end of file
...@@ -10,6 +10,7 @@ export default class { ...@@ -10,6 +10,7 @@ export default class {
] ]
] ]
])}> ])}>
<p className={_JSXStyle.dynamic([ <p className={_JSXStyle.dynamic([
[ [
"eb1d88515aa07b6b", "eb1d88515aa07b6b",
...@@ -19,12 +20,14 @@ export default class { ...@@ -19,12 +20,14 @@ export default class {
] ]
] ]
])}>test</p> ])}>test</p>
<_JSXStyle id={"eb1d88515aa07b6b"} dynamic={[ <_JSXStyle id={"eb1d88515aa07b6b"} dynamic={[
a || "var(--c)", a || "var(--c)",
b || "inherit" b || "inherit"
]}>{`.a .b.__jsx-style-dynamic-selector {display:inline-block; ]}>{`.a:hover .b.__jsx-style-dynamic-selector {display:inline-block;
padding:0 ${a || "var(--c)"}; padding:0 ${a || "var(--c)"};
color:${b || "inherit"}}`}</_JSXStyle> color:${b || "inherit"}}`}</_JSXStyle>
</div>; </div>;
} }
} };
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment