mutate node outside of the walk
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
This commit is contained in:
parent
1ceea2ff77
commit
f7382fedbc
1 changed files with 6 additions and 1 deletions
|
|
@ -447,6 +447,7 @@ export function createVariants(theme: Theme): Variants {
|
|||
if (variant.modifier) return null
|
||||
|
||||
let didApply = false
|
||||
let replacement: AstNode | null = null
|
||||
|
||||
walk([ruleNode], (node, ctx) => {
|
||||
if (node.kind !== 'rule' && node.kind !== 'at-rule') return WalkAction.Continue
|
||||
|
|
@ -492,7 +493,7 @@ export function createVariants(theme: Theme): Variants {
|
|||
rules.push(negatedAtRule)
|
||||
}
|
||||
|
||||
Object.assign(ruleNode, styleRule('&', rules))
|
||||
replacement = styleRule('&', rules)
|
||||
|
||||
// Track that the variant was actually applied
|
||||
didApply = true
|
||||
|
|
@ -500,6 +501,10 @@ export function createVariants(theme: Theme): Variants {
|
|||
return WalkAction.Skip
|
||||
})
|
||||
|
||||
if (replacement) {
|
||||
Object.assign(ruleNode, replacement)
|
||||
}
|
||||
|
||||
// TODO: Tweak group, peer, has to ignore intermediate `&` selectors (maybe?)
|
||||
if (ruleNode.kind === 'rule' && ruleNode.selector === '&' && ruleNode.nodes.length === 1) {
|
||||
Object.assign(ruleNode, ruleNode.nodes[0])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue