@@ -195,10 +195,21 @@ export default () => Parser => {
195
195
* values without affect any other part of the process.
196
196
*/
197
197
this [ STATE ] . templateElements . forEach ( templateElement => {
198
- const terminalDollarBraceL = this . input . slice ( templateElement . end , templateElement . end + 2 ) === "${" ;
198
+ const startOffset = - 1 ;
199
+ const endOffset = templateElement . tail ? 1 : 2 ;
199
200
200
- templateElement . start -- ;
201
- templateElement . end += ( terminalDollarBraceL ? 2 : 1 ) ;
201
+ templateElement . start += startOffset ;
202
+ templateElement . end += endOffset ;
203
+
204
+ if ( templateElement . range ) {
205
+ templateElement . range [ 0 ] += startOffset ;
206
+ templateElement . range [ 1 ] += endOffset ;
207
+ }
208
+
209
+ if ( templateElement . loc ) {
210
+ templateElement . loc . start . column += startOffset ;
211
+ templateElement . loc . end . column += endOffset ;
212
+ }
202
213
} ) ;
203
214
204
215
return program ;
@@ -295,19 +306,6 @@ export default () => Parser => {
295
306
// so we have to adjust ranges/locations appropriately.
296
307
if ( result . type === "TemplateElement" ) {
297
308
298
- // additional adjustment needed if ${ is the last token
299
- const terminalDollarBraceL = this . input . slice ( result . end , result . end + 2 ) === "${" ;
300
-
301
- if ( result . range ) {
302
- result . range [ 0 ] -- ;
303
- result . range [ 1 ] += ( terminalDollarBraceL ? 2 : 1 ) ;
304
- }
305
-
306
- if ( result . loc ) {
307
- result . loc . start . column -- ;
308
- result . loc . end . column += ( terminalDollarBraceL ? 2 : 1 ) ;
309
- }
310
-
311
309
// save template element references to fix start/end later
312
310
this [ STATE ] . templateElements . push ( result ) ;
313
311
}
0 commit comments