Stylis V4 compatibility#11
Conversation
|
Thank you for the PR - I'll try to review this somewhat soon, but truth to be told this requires some focus and this is not on the top of my priority list so it might take me some time to get back to it. |
|
This implementation causes weird issues with the .some-class {
&.something-else {
...the parent node is modified to I tried to remedy this by keeping track of modified parent nodes in a |
|
I would literally set up tests with Emotion here to test this. I'm not sure why Emotion would make it to affect children. Nodes are actually generated by Stylis and while some object references are shared within the "tree" the generated rules should not be affected like this. Maybe it's the |
|
Thanks for the lead! Placing this plugin ahead of Looking at the Stylis source code, it appears that each node passes through each plugin before moving on to the next node. The |
|
The latest version of @emotion/react doesn't work from the master branch - is this PR going to be merged soon? |
| for (let i = 0; i < selectors.length; i++) { | ||
| selectors[i] = scopes.map(scope => `${scope}${selectors[i]}`).join(',') | ||
| if ( | ||
| !element.parent || |
There was a problem hiding this comment.
Could you explain the logic behind those conditions here? writing Stylis plugins is tricky and I would like to recheck the thought process behind this - I'm not saying there is anything wrong with it, it would just make it easier for me to review it
There was a problem hiding this comment.
I'm no longer working on the project that I wrote this for so I can't test out exactly what CSS elements this is targeting, but I do know that it's targeting elements that pass through the compat plugin unchanged. Without this logic, the extra scope would be applied to nested selectors and pseudo-selectors before being joined to parent selectors by compat, resulting in the "joined" selector including repeated references to the extra scope.
|
I can confirm this PR is working fine together with styled-components v5.2.1 which is using v4 of stylis. |
|
Styled Components v5 is not using Stylis v4 yet: https://github.com/styled-components/styled-components/blob/v5.2.1/packages/styled-components/package.json#L69 |
|
Oh strange. looks like on the master branch they are using it: https://github.com/styled-components/styled-components/blob/master/packages/styled-components/package.json#L73 So I'm not sure from which branch they released v5.2.1 |
|
Hello, I was just wondering what the blockers are for this plugin fix? From the comments, the problems seem to be resolved? |
|
the main blocker is my lack of time to focus on this one |
|
Is there anything more external users (like myself) can do to help you? Or is just a matter of the repo owner finishing the PR vetting + release? For now, I've just copied the potential changes and am using them in a local lib file, but I would love to seem them as part of the normal npm registry! |
|
If you could recheck the implementation - preferably with some notes on why it is written in a way that it is written - this would help a lot. I suspect that this version might not work properly with nested at rules but I have also not checked it. In general, I'm not confident with merging this without understanding the thought process behind this implementation. I'm not saying that it's incorrect or wrong - it's just that Stylis plugins are quite tricky to get right. Preparing PR that would merge master to this branch would also be helpful as this has some conflicts right now. |
|
Re:
This comment in the compat plugin seems suspicious: // if this is an implicitly inserted rule (the one eagerly inserted at the each new nested level)
// then the props has already been manipulated beforehand as they that array is shared between it and its "rule parent" |
|
Is there any update on the status of this PR? Would be great to get this plugin updated. |
|
Any updates on this? |
|
Going to close this out in favour of #14 |
Adds compatibility for Stylis V4.
I've added an explicit check for
@keyframes. Are there any other at-rules whose properties should be exempt from extra scoping?