Skip to content

Commit 24a1192

Browse files
committed
fix: include end in plain node; rename offset to start in plain node
1 parent 10a965c commit 24a1192

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/api.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,8 @@ describe('CSSNode', () => {
11891189

11901190
expect(clone.line).toBeUndefined()
11911191
expect(clone.column).toBeUndefined()
1192-
expect(clone.offset).toBeUndefined()
1192+
expect(clone.start).toBeUndefined()
1193+
expect(clone.end).toBeUndefined()
11931194
expect(clone.length).toBeUndefined()
11941195
})
11951196

@@ -1201,7 +1202,8 @@ describe('CSSNode', () => {
12011202

12021203
expect(clone.line).toBeDefined()
12031204
expect(clone.column).toBeDefined()
1204-
expect(clone.offset).toBeDefined()
1205+
expect(clone.start).toBeDefined()
1206+
expect(clone.end).toBeDefined()
12051207
expect(clone.length).toBeDefined()
12061208
})
12071209

src/css-node.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export interface CloneOptions {
136136
*/
137137
deep?: boolean
138138
/**
139-
* Include location information (line, column, offset, length)
139+
* Include location information (line, column, start, length)
140140
* @default false
141141
*/
142142
locations?: boolean
@@ -171,8 +171,9 @@ export type PlainCSSNode = {
171171
// Location (only when locations: true)
172172
line?: number
173173
column?: number
174-
offset?: number
174+
start?: number
175175
length?: number
176+
end?: number
176177
}
177178

178179
export class CSSNode {
@@ -689,7 +690,7 @@ export class CSSNode {
689690
*
690691
* @param options - Cloning configuration
691692
* @param options.deep - Recursively clone children (default: true)
692-
* @param options.locations - Include line/column/offset/length (default: false)
693+
* @param options.locations - Include line/column/start/length (default: false)
693694
* @returns Plain object with children as array
694695
*
695696
* @example
@@ -747,8 +748,9 @@ export class CSSNode {
747748
if (locations) {
748749
plain.line = this.line
749750
plain.column = this.column
750-
plain.offset = this.start
751+
plain.start = this.start
751752
plain.length = this.length
753+
plain.end = this.end
752754
}
753755

754756
// 8. Deep clone children - just push to array!

0 commit comments

Comments
 (0)