Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle root-level ampersands gracefully #153

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions index.test.js
Expand Up @@ -775,4 +775,32 @@ test('The rooRuleName option may start with "@"', () => {
})
})

test('selector-less curly-brace blocks are removed from output', () => {
run(
'{ a {color:white} { b {color:red;} } }',
'a {color:white} b {color:red;}'
)
})

test('root-level `&` is removed from output', () => {
run(
'a {color:white} & { b {color:red;} c & { & { color:green; } } & d {color:blue;} }',
'a {color:white} b {color:red;} c {color:green;} d {color:blue;}'
)
})

test('root level `&` inside @media is removed', () => {
run(
'@media screen { & { a {color:red;} b & {color:green;} } }',
'@media screen { a {color:red;} b {color:green;} }'
)
})

test('root level `&` with @media inside is removed', () => {
run(
'& { @media screen { a {color:red;} b & {color:green;} } }',
'@media screen { a {color:red;} b {color:green;} }'
)
})

test.run()