Description
Bug description
Hello!
We have recently upgraded postcss
and its plugins (including postcss-nesting
) and noticed unexpected style orders in some places.
After some digging and debugging, it turned out that the differences come from postcss-nesting
and nested @mixin
rules interaction implemented in the groupDeclarations
function.
Our previous assumption was that all styles from mixins would be placed exactly where the mixin was used. However, this behavior has been affected by the new grouping and reordering mechanism.
I’ve attempted to address this issue in the forked repo, but before submitting a pull request, I’d like to confirm whether this behavior is intentional or unintended. If it’s intentional, any hints/details will be welcome 😃
Link to my changes: main...pciarach:postcss-plugins:fix/nested-mixins-reorder
Source CSS
@define-mixin mixinToOverride {
display: flex;
}
@define-mixin mixinWithDecl {
color: blue;
}
@define-mixin nestedMixins {
@mixin mixinWithDecl;
@mixin mixinToOverride;
&:disabled {
color: white;
}
}
a {
color: yellow;
& b {
@mixin nestedMixins;
display: inline-flex;
}
}
Expected CSS
a {
color: yellow;
}
a b {
color: blue;
display: flex;
display: inline-flex;
}
a b:disabled {
color: white;
}
Actual CSS
a {
color: yellow;
}
a b {
color: blue;
display: inline-flex;
display: flex;
}
a b:disabled {
color: white;
}
Playgound example
No response
Does it happen with npx @csstools/csstools-cli <plugin-name> minimal-example.css
?
None
Debug output
No response
Extra config
No response
What plugin are you experiencing this issue on?
PostCSS Nesting
Plugin version
12.0.3
What OS are you experiencing this on?
Windows
Node Version
20.11.0
Validations
- Follow our Code of Conduct
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Would you like to open a PR for this bug?
- I'm willing to open a PR