Unverified Commit 1e2fb0bb authored by Maia Teegarden's avatar Maia Teegarden Committed by GitHub

Fix redundant styled-jsx global issue (#30584)

Fixes https://github.com/vercel/styled-jsx/issues/756

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
parent d03ce161
......@@ -155,10 +155,6 @@ impl Namespacer {
&mut self,
mut node: CompoundSelector,
) -> Result<Vec<CompoundSelector>, Error> {
if self.is_global {
return Ok(vec![node]);
}
let mut pseudo_index = None;
for (i, selector) in node.subclass_selectors.iter().enumerate() {
if let SubclassSelector::Pseudo(PseudoSelector { name, args, .. }) = selector {
......@@ -216,17 +212,19 @@ impl Namespacer {
None => node.subclass_selectors.len(),
Some(i) => i,
};
node.subclass_selectors.insert(
insert_index,
SubclassSelector::Class(ClassSelector {
span: DUMMY_SP,
text: Text {
raw: subclass_selector.into(),
value: subclass_selector.into(),
if !self.is_global {
node.subclass_selectors.insert(
insert_index,
SubclassSelector::Class(ClassSelector {
span: DUMMY_SP,
},
}),
);
text: Text {
raw: subclass_selector.into(),
value: subclass_selector.into(),
span: DUMMY_SP,
},
}),
);
}
Ok(vec![node])
}
......
export default function IndexPage() {
return (
<div>
should be blue.
<style jsx global>{`
:global(div) {
color: blue;
}
`}</style>
</div>
);
}
import _JSXStyle from "styled-jsx/style";
export default function IndexPage() {
return <div className={"jsx-b6abd0684ba81871"}>
should be blue.
<_JSXStyle id={"b6abd0684ba81871"}>{"div {color:blue}"}</_JSXStyle>
</div>;
};
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