-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Closed
Description
Using the @Variants function with rules that have multiple selectors does not work as I expected it to.
Say I have the following CSS:
@variants hover {
.a, .b {
color: red
}
}This is what I expect to be output:
.hover\:a:hover, .hover\:b:hover {
color: red
}... but this is what I actually get:
.hover\:a, .b:hover {
color: red
}In this file:
https://github.com/tailwindcss/tailwindcss/blob/37493edfc7d7118c416470fa718d8e65e1bb35f0/src/util/generateVariantFunction.js
We have this block of code:
modifySelectors: modifierFunction => {
cloned.walkRules(rule => {
rule.selector = modifierFunction({
className: rule.selector.slice(1),
selector: rule.selector,
})
})
return cloned
},In my opinion, I feel like using rule.selector here is causing the unexpected behaviour.
Would it be better to map over the rule.selectors property instead (like below)?
modifySelectors: modifierFunction => {
cloned.walkRules(rule => {
rule.selectors = rule.selectors.map(selector =>
modifierFunction({
className: selector.slice(1),
selector: selector
})
);
});
return cloned;
}spiltcoffee
Metadata
Metadata
Assignees
Labels
No labels