@@ -34,11 +34,8 @@ function cloneNode(obj, parent) {
3434
3535function sourceOffset ( inputCSS , position ) {
3636 // 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
4239 }
4340
4441 let column = 1
@@ -213,9 +210,10 @@ class Node {
213210 if ( opts . index ) {
214211 pos = this . positionInside ( opts . index )
215212 } 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
219217 let stringRepresentation = inputString . slice (
220218 sourceOffset ( inputString , this . source . start ) ,
221219 sourceOffset ( inputString , this . source . end )
@@ -229,9 +227,10 @@ class Node {
229227 positionInside ( index ) {
230228 let column = this . source . start . column
231229 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
235234 let offset = sourceOffset ( inputString , this . source . start )
236235 let end = offset + index
237236
@@ -254,9 +253,10 @@ class Node {
254253 }
255254
256255 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
260260 let start = {
261261 column : this . source . start . column ,
262262 line : this . source . start . line ,
@@ -266,13 +266,14 @@ class Node {
266266 ? {
267267 column : this . source . end . column + 1 ,
268268 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
276277 }
277278 : {
278279 column : start . column + 1 ,
@@ -288,9 +289,7 @@ class Node {
288289 let index = stringRepresentation . indexOf ( opts . word )
289290 if ( index !== - 1 ) {
290291 start = this . positionInside ( index )
291- end = this . positionInside (
292- index + opts . word . length ,
293- )
292+ end = this . positionInside ( index + opts . word . length )
294293 }
295294 } else {
296295 if ( opts . start ) {
@@ -399,9 +398,7 @@ class Node {
399398 } else if ( typeof value === 'object' && value . toJSON ) {
400399 fixed [ name ] = value . toJSON ( null , inputs )
401400 } else if ( name === 'source' ) {
402- if ( value == null ) {
403- continue ;
404- }
401+ if ( value == null ) continue
405402 let inputId = inputs . get ( value . input )
406403 if ( inputId == null ) {
407404 inputId = inputsNextIndex
0 commit comments