Open mxmul opened 4 years ago
It would be great to fix this but I must say that this is not the top priority for us and I might not find the time to implement a fix for this myself.
@Andarist are you open to a PR then? I could look into this myself
Sure thing! PRs are always welcome. I would prefer a PR against the next
branch though. Please propose a solution before jumping right into coding - I'll be able to tell you if the proposed solution solves potential edge cases etc.
Would a pure Stylis solution of serialize(compile(input), [stringify])
produce the desired effect? i.e. get stylis to parse the CSS, then spit it out again using its stringify
middleware, which does the whitespace stripping?
That was literally my first intuition as well but Stylis v4 doesnt normalize whitespace in parenthesis :s
Yikes, so it'll need to be that plus a little custom plugin that tidies up values inside decl
StyleElements...
Yeah, probably something like that - we could actually use a minifier plugin that would be used to optimize whitespace in our precomputed styles when using Babel plugin, so this could serve both cases.
Please always try to share a repro case in a runnable form - either by providing a git repository to clone or a codesandbox. OSS maintainers usually can't afford the time to set up the repro, even if exact steps are given.
Please always try to share a repro case in a runnable form - either by providing a git repository to clone or a codesandbox. OSS maintainers usually can't afford the time to set up the repro, even if exact steps are given.
I will investigate further and reply with a repo instead!
Current behavior:
Emotion is stripping some whitespace from style rules, which makes it difficult to assert that a JS variable exists in emitted styles.
For example, if I have defined color token like this:
and I use it in a styled component, the Jest matcher considers the color value to be different:
To reproduce:
$ yarn
$ yarn test
Expected behavior:
Whatever transformations Emotion is applying to CSS property values should also be applied to the values passed to
toHaveStyleRule
. It should treatrgb(255, 0, 0)
andrgb(255,0,0)
as equivalent.Environment information:
react
version: 16.13.1emotion
version: 10.0.35