Skip to content

Commit 67379cc

Browse files
authored
Fix for declarations after nested rule && before at-rule (#95)
1 parent bc9502e commit 67379cc

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ function processRule (rule, bubble, unwrap, preserveEmpty) {
125125
} else if (child.type === 'atrule') {
126126
copyDeclarations = false
127127

128+
if (declarations.length) {
129+
after = pickDeclarations(rule.selector, declarations, after)
130+
declarations = []
131+
}
132+
128133
if (child.name === 'at-root') {
129134
unwrapped = true
130135
atruleChilds(rule, child, false)

index.test.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ it('copies rule for declarations after nested rule', () => {
193193
)
194194
})
195195

196+
it('copies rule for declarations after nested rule and before at-rule', () => {
197+
return run(
198+
'a { &b { a: 1 } b: 2; @media { c: 3 } }',
199+
'ab { a: 1 } a { b: 2 } @media {a { c: 3 } }'
200+
)
201+
})
202+
196203
it('does not replace ampersand inside string', () => {
197204
return run(
198205
'div { &[data-category="sound & vision"] {} }',

0 commit comments

Comments
 (0)