@@ -20,7 +20,7 @@ const { createRecord, rerender, reload } = __VUE_HMR_RUNTIME__
20
20
registerRuntimeCompiler ( compileToFunction )
21
21
22
22
function compileToFunction ( template : string ) {
23
- const { code } = baseCompile ( template )
23
+ const { code } = baseCompile ( template , { hoistStatic : true , hmr : true } )
24
24
const render = new Function ( 'Vue' , code ) (
25
25
runtimeTest
26
26
) as InternalRenderFunction
@@ -567,4 +567,40 @@ describe('hot module replacement', () => {
567
567
rerender ( parentId , compileToFunction ( `<Child>2</Child>` ) )
568
568
expect ( serializeInner ( root ) ) . toBe ( `2` )
569
569
} )
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
+ } )
570
606
} )
0 commit comments