@@ -157,6 +157,35 @@ test('source map', () => {
157157 ) . toMatchObject ( getPositionInCode ( template . content , `foobar` ) )
158158} )
159159
160+ test ( 'source map: v-if generated comment should not have original position' , ( ) => {
161+ const template = parse (
162+ `
163+ <template>
164+ <div v-if="true"></div>
165+ </template>
166+ ` ,
167+ { filename : 'example.vue' , sourceMap : true } ,
168+ ) . descriptor . template !
169+
170+ const { code, map } = compile ( {
171+ filename : 'example.vue' ,
172+ source : template . content ,
173+ } )
174+
175+ expect ( map ! . sources ) . toEqual ( [ `example.vue` ] )
176+ expect ( map ! . sourcesContent ) . toEqual ( [ template . content ] )
177+
178+ const consumer = new SourceMapConsumer ( map as RawSourceMap )
179+ const commentNode = code . match ( / _ c r e a t e C o m m e n t V N o d e \( " v - i f " , t r u e \) / )
180+ expect ( commentNode ) . not . toBeNull ( )
181+ const commentPosition = getPositionInCode ( code , commentNode ! [ 0 ] )
182+ const originalPosition = consumer . originalPositionFor ( commentPosition )
183+ // the comment node should not be mapped to the original source
184+ expect ( originalPosition . column ) . toBeNull ( )
185+ expect ( originalPosition . line ) . toBeNull ( )
186+ expect ( originalPosition . source ) . toBeNull ( )
187+ } )
188+
160189test ( 'should work w/ AST from descriptor' , ( ) => {
161190 const source = `
162191 <template>
0 commit comments