-
Notifications
You must be signed in to change notification settings - Fork 40
Conversation
These are now in the order of the apply declaration but still obey the cascade order so pt-/pb- still wins over py- and py still wins over p-
I think this logic is too specific but it seems to work for now
5745eb3
to
a899135
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! Thank you for your PR!
Much appreciated! 🙏
It's looking very promising, just found a little bug!
If you like, I can update the PR for you, but just wanted to let you know about what I found.
src/lib/expandApplyAtRules.js
Outdated
|
||
root.walkRules((rule) => { | ||
rule.selector = replaceSelector(apply.parent.selector, rule.selector, applyCandidate) | ||
if (canRewriteSelector) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good, however I think we can improve this a little bit.
Inside keyframes, you are not allowed to have !important
, this is invalid:
@keyframes spin {
to {
transform: rotate(360deg) !important;
}
}
But since the if (canRewriteSelector)
is only wrapping the rule.selector = ...
change, this walkDecls
to change the important
will still happen.
We can fix that, and we can also skip the whole root.walkRules
I think:
if (canRewriteSelector) {
root.walkRules((rule) => {
rule.selector = replaceSelector(
apply.parent.selector,
rule.selector,
applyCandidate
)
rule.walkDecls((d) => {
d.important = important
})
})
}
You can see this behaviour when you do this:
.foo {
@apply animate-spin !important;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You know I thought about this — I wasn't sure if that was invalid or not so I left it just in case. I've updated the implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thanks!
Fixes #94