@@ -20,7 +20,7 @@ const { createRecord, rerender, reload } = __VUE_HMR_RUNTIME__
2020registerRuntimeCompiler ( compileToFunction )
2121
2222function compileToFunction ( template : string ) {
23- const { code } = baseCompile ( template )
23+ const { code } = baseCompile ( template , { hoistStatic : true , hmr : true } )
2424 const render = new Function ( 'Vue' , code ) (
2525 runtimeTest
2626 ) as InternalRenderFunction
@@ -567,4 +567,40 @@ describe('hot module replacement', () => {
567567 rerender ( parentId , compileToFunction ( `<Child>2</Child>` ) )
568568 expect ( serializeInner ( root ) ) . toBe ( `2` )
569569 } )
570+
571+ // #6978, #7138, #7114
572+ test ( 'hoisted children array inside v-for' , ( ) => {
573+ const root = nodeOps . createElement ( 'div' )
574+ const appId = 'test-app-id'
575+ const App : ComponentOptions = {
576+ __hmrId : appId ,
577+ render : compileToFunction (
578+ `<div v-for="item of 2">
579+ <div>1</div>
580+ </div>
581+ <p>2</p>
582+ <p>3</p>`
583+ )
584+ }
585+ createRecord ( appId , App )
586+
587+ render ( h ( App ) , root )
588+ expect ( serializeInner ( root ) ) . toBe (
589+ `<div><div>1</div></div><div><div>1</div></div><p>2</p><p>3</p>`
590+ )
591+
592+ // move the <p>3</p> into the <div>1</div>
593+ rerender (
594+ appId ,
595+ compileToFunction (
596+ `<div v-for="item of 2">
597+ <div>1<p>3</p></div>
598+ </div>
599+ <p>2</p>`
600+ )
601+ )
602+ expect ( serializeInner ( root ) ) . toBe (
603+ `<div><div>1<p>3</p></div></div><div><div>1<p>3</p></div></div><p>2</p>`
604+ )
605+ } )
570606} )
0 commit comments