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

invalid sourcemap with at layer #1801

Merged
Show file tree
Hide file tree
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 test/at-rule.test.ts
Expand Up @@ -48,4 +48,32 @@ test('clone spaces from another at-rule', () => {
is(rule.toString(), '@page 1{}')
})

test('at layer', () => {
let root = parse(`@layer foo {\n @layer one, two\n}`)
let layer1 = root.nodes[0] as AtRule;
let layer2 = layer1.nodes[0] as AtRule;

is(root.source?.start?.offset, 0)
is(root.source?.start?.line, 1)
is(root.source?.start?.column, 1)

is(layer1.source?.start?.offset, 0)
is(layer1.source?.start?.line, 1)
is(layer1.source?.start?.column, 1)

is(layer1.source?.end?.offset, 31)
is(layer1.source?.end?.line, 3)
is(layer1.source?.end?.column, 1)

is(layer2.source?.start?.offset, 15)
is(layer2.source?.start?.line, 2)
is(layer2.source?.start?.column, 3)

is(layer2.source?.end?.offset, 29)
is(layer2.source?.end?.line, 2)
is(layer2.source?.end?.column, 17)

is(root.toString(), '@layer foo {\n @layer one, two\n}')
})

test.run()
15 changes: 15 additions & 0 deletions test/map.test.ts
Expand Up @@ -104,6 +104,21 @@ test('generate right source map', () => {
})
})

test('generate right source map for at layer', () => {
let css = '@layer extensions {\n @layer one, two\n}'
let processor = postcss(() => {
/* noop */
})

let result = processor.process(css, {
from: 'a.css',
to: 'b.css',
map: true
})

read(result)
})

test('changes previous source map', () => {
let css = 'a { color: black }'

Expand Down