@@ -34,11 +34,8 @@ function cloneNode(obj, parent) {
34
34
35
35
function sourceOffset ( inputCSS , position ) {
36
36
// Not all custom syntaxes support `offset` in `source.start` and `source.end`
37
- if (
38
- position &&
39
- typeof position . offset !== 'undefined'
40
- ) {
41
- return position . offset ;
37
+ if ( position && typeof position . offset !== 'undefined' ) {
38
+ return position . offset
42
39
}
43
40
44
41
let column = 1
@@ -213,9 +210,10 @@ class Node {
213
210
if ( opts . index ) {
214
211
pos = this . positionInside ( opts . index )
215
212
} else if ( opts . word ) {
216
- let inputString = ( 'document' in this . source . input )
217
- ? this . source . input . document
218
- : this . source . input . css
213
+ let inputString =
214
+ 'document' in this . source . input
215
+ ? this . source . input . document
216
+ : this . source . input . css
219
217
let stringRepresentation = inputString . slice (
220
218
sourceOffset ( inputString , this . source . start ) ,
221
219
sourceOffset ( inputString , this . source . end )
@@ -229,9 +227,10 @@ class Node {
229
227
positionInside ( index ) {
230
228
let column = this . source . start . column
231
229
let line = this . source . start . line
232
- let inputString = ( 'document' in this . source . input )
233
- ? this . source . input . document
234
- : this . source . input . css
230
+ let inputString =
231
+ 'document' in this . source . input
232
+ ? this . source . input . document
233
+ : this . source . input . css
235
234
let offset = sourceOffset ( inputString , this . source . start )
236
235
let end = offset + index
237
236
@@ -254,9 +253,10 @@ class Node {
254
253
}
255
254
256
255
rangeBy ( opts = { } ) {
257
- let inputString = ( 'document' in this . source . input )
258
- ? this . source . input . document
259
- : this . source . input . css
256
+ let inputString =
257
+ 'document' in this . source . input
258
+ ? this . source . input . document
259
+ : this . source . input . css
260
260
let start = {
261
261
column : this . source . start . column ,
262
262
line : this . source . start . line ,
@@ -266,13 +266,14 @@ class Node {
266
266
? {
267
267
column : this . source . end . column + 1 ,
268
268
line : this . source . end . line ,
269
- offset : typeof this . source . end . offset === 'number'
270
- // `source.end.offset` is exclusive, so we don't need to add 1
271
- ? this . source . end . offset
272
- // Since line/column in this.source.end is inclusive,
273
- // the `sourceOffset(... , this.source.end)` returns an inclusive offset.
274
- // So, we add 1 to convert it to exclusive.
275
- : sourceOffset ( inputString , this . source . end ) + 1
269
+ offset :
270
+ typeof this . source . end . offset === 'number'
271
+ ? // `source.end.offset` is exclusive, so we don't need to add 1
272
+ this . source . end . offset
273
+ : // Since line/column in this.source.end is inclusive,
274
+ // the `sourceOffset(... , this.source.end)` returns an inclusive offset.
275
+ // So, we add 1 to convert it to exclusive.
276
+ sourceOffset ( inputString , this . source . end ) + 1
276
277
}
277
278
: {
278
279
column : start . column + 1 ,
@@ -288,9 +289,7 @@ class Node {
288
289
let index = stringRepresentation . indexOf ( opts . word )
289
290
if ( index !== - 1 ) {
290
291
start = this . positionInside ( index )
291
- end = this . positionInside (
292
- index + opts . word . length ,
293
- )
292
+ end = this . positionInside ( index + opts . word . length )
294
293
}
295
294
} else {
296
295
if ( opts . start ) {
@@ -399,9 +398,7 @@ class Node {
399
398
} else if ( typeof value === 'object' && value . toJSON ) {
400
399
fixed [ name ] = value . toJSON ( null , inputs )
401
400
} else if ( name === 'source' ) {
402
- if ( value == null ) {
403
- continue ;
404
- }
401
+ if ( value == null ) continue
405
402
let inputId = inputs . get ( value . input )
406
403
if ( inputId == null ) {
407
404
inputId = inputsNextIndex
0 commit comments