Skip to content

Commit

Permalink
Merge pull request #1801 from romainmenke/invalid-sourcemap-with-at-l…
Browse files Browse the repository at this point in the history
…ayer--practical-grey-mouse-lemur-3c469975f4

invalid sourcemap with at layer
  • Loading branch information
ai committed Dec 11, 2022
2 parents d585976 + db935f1 commit ff7e8ce
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
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

0 comments on commit ff7e8ce

Please sign in to comment.