-
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: node end offset location (#147)
* chore: upgrade postcss deps * chore: broken postcss-parser-tests usage - cases are already parsed - https://github.com/postcss/postcss-parser-tests/blob/main/CHANGELOG.md#87 - postcss/postcss-parser-tests@442f6dc * fix: offset in sass specific parsing
- Loading branch information
Showing
5 changed files
with
56 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
let { equal } = require('uvu/assert') | ||
let { test } = require('uvu') | ||
|
||
let parse = require('../lib/scss-parse') | ||
|
||
function checkOffset(source, node, expected) { | ||
let start = node.source.start.offset | ||
let end = node.source.end.offset | ||
equal(source.slice(start, end), expected) | ||
} | ||
|
||
test('inline comment', () => { | ||
let source = 'a{//xxx\n}' | ||
let root = parse(source) | ||
|
||
checkOffset(source, root.first, 'a{//xxx\n}') | ||
checkOffset(source, root.first.first, '//xxx') | ||
}) | ||
|
||
test('nested prop with value', () => { | ||
let source = 'a { margin: 0 { left: 10px; }}' | ||
let root = parse(source) | ||
|
||
checkOffset(source, root.first, 'a { margin: 0 { left: 10px; }}') | ||
checkOffset(source, root.first.first, 'margin: 0 { left: 10px; }') | ||
checkOffset(source, root.first.first.first, 'left: 10px;') | ||
}) | ||
|
||
test.run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters