Skip to content

Commit

Permalink
Fix for declarations after nested rule && before at-rule (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
demikhovr authored Jul 9, 2020
1 parent bc9502e commit 67379cc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ function processRule (rule, bubble, unwrap, preserveEmpty) {
} else if (child.type === 'atrule') {
copyDeclarations = false

if (declarations.length) {
after = pickDeclarations(rule.selector, declarations, after)
declarations = []
}

if (child.name === 'at-root') {
unwrapped = true
atruleChilds(rule, child, false)
Expand Down
7 changes: 7 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,13 @@ it('copies rule for declarations after nested rule', () => {
)
})

it('copies rule for declarations after nested rule and before at-rule', () => {
return run(
'a { &b { a: 1 } b: 2; @media { c: 3 } }',
'ab { a: 1 } a { b: 2 } @media {a { c: 3 } }'
)
})

it('does not replace ampersand inside string', () => {
return run(
'div { &[data-category="sound & vision"] {} }',
Expand Down

0 comments on commit 67379cc

Please sign in to comment.