-
Notifications
You must be signed in to change notification settings - Fork 11
Closed
Labels
Description
I found some behavior that I think is incorrect.
Example HTML:
<div class="a">
<div class="b">hello</div>
</div>Example input CSS:
.b { background: red }
.a .b { color: blue }Example output CSS:
.b, .a .b { background: initial; color: initial }
.b { background: red }
.a .b { color: blue }Before being run through postcss-autoreset, div.b is background: red. But afterwards, it becomes background: initial because the reset rule for .a .b has higher specificity. That smells like a bug to me.
I think this plugin should only reset selectors that have a single component. There's no reason to reset .b and then also reset .a .b – it's just a waste of bytes.
In the meantime, I was able to work around the issue with this config:
require('postcss-autoreset')({
rulesMatcher: (rule) => rule.selector.match(/^[.][\w-]+$/),
}),