-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
Description
Summary
In f09e296, offset property is added to Node.Position. But, the property is wrong value in some cases. The offset is 1 larger than expected.
Reproduction
import { Declaration, parse, Rule } from 'postcss';
const css = parse('a { one: X }');
const a = css.first as Rule;
let one = a.first as Declaration;
console.log(css.source?.end); // ok
console.log(a.source?.end); // NG
console.log(one.source?.end); // NG$ npm start
> start
> ts-node index.ts
{ column: 13, line: 1, offset: 12 }
{ column: 12, line: 1, offset: 12 }
{ column: 10, line: 1, offset: 10 }Expected Behavior
The following will be output:
$ npm start
> start
> ts-node index.ts
{ column: 13, line: 1, offset: 12 }
{ column: 12, line: 1, offset: 11 }
{ column: 10, line: 1, offset: 9 }Additional Information
- I discovered this behavior while working on Add
CssSyntaxError.offsetandCssSyntaxError.endOffset#2022. - I can send a pull request to fix it.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels