@@ -229,8 +229,8 @@ class Node {
229229 return fixed
230230 }
231231
232- positionInside ( index ) {
233- let string = this . toString ( )
232+ positionInside ( index , stringRepresentation ) {
233+ let string = stringRepresentation || this . toString ( )
234234 let column = this . source . start . column
235235 let line = this . source . start . line
236236
@@ -246,13 +246,14 @@ class Node {
246246 return { line, column }
247247 }
248248
249- positionBy ( opts ) {
249+ positionBy ( opts , stringRepresentation ) {
250250 let pos = this . source . start
251251 if ( opts . index ) {
252- pos = this . positionInside ( opts . index )
252+ pos = this . positionInside ( opts . index , stringRepresentation )
253253 } else if ( opts . word ) {
254- let index = this . toString ( ) . indexOf ( opts . word )
255- if ( index !== - 1 ) pos = this . positionInside ( index )
254+ stringRepresentation = this . toString ( )
255+ let index = stringRepresentation . indexOf ( opts . word )
256+ if ( index !== - 1 ) pos = this . positionInside ( index , stringRepresentation )
256257 }
257258 return pos
258259 }
@@ -264,19 +265,20 @@ class Node {
264265 }
265266 let end = this . source . end
266267 ? {
267- line : this . source . end . line ,
268- column : this . source . end . column + 1
269- }
268+ line : this . source . end . line ,
269+ column : this . source . end . column + 1
270+ }
270271 : {
271- line : start . line ,
272- column : start . column + 1
273- }
272+ line : start . line ,
273+ column : start . column + 1
274+ }
274275
275276 if ( opts . word ) {
276- let index = this . toString ( ) . indexOf ( opts . word )
277+ let stringRepresentation = this . toString ( )
278+ let index = stringRepresentation . indexOf ( opts . word )
277279 if ( index !== - 1 ) {
278- start = this . positionInside ( index )
279- end = this . positionInside ( index + opts . word . length )
280+ start = this . positionInside ( index , stringRepresentation )
281+ end = this . positionInside ( index + opts . word . length , stringRepresentation )
280282 }
281283 } else {
282284 if ( opts . start ) {
0 commit comments