@@ -21,7 +21,7 @@ const { createRecord, rerender, reload } = __VUE_HMR_RUNTIME__
21
21
registerRuntimeCompiler ( compileToFunction )
22
22
23
23
function compileToFunction ( template : string ) {
24
- const { code } = baseCompile ( template )
24
+ const { code } = baseCompile ( template , { hoistStatic : true } )
25
25
const render = new Function ( 'Vue' , code ) (
26
26
runtimeTest
27
27
) as InternalRenderFunction
@@ -568,4 +568,32 @@ describe('hot module replacement', () => {
568
568
rerender ( parentId , compileToFunction ( `<Child>2</Child>` ) )
569
569
expect ( serializeInner ( root ) ) . toBe ( `2` )
570
570
} )
571
+
572
+ test ( 'rerender in change hoisted nodes' , ( ) => {
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"><div>1</div></div><p>2</p><p>3</p>`
579
+ )
580
+ }
581
+ createRecord ( appId , App )
582
+
583
+ render ( h ( App ) , root )
584
+ expect ( serializeInner ( root ) ) . toBe (
585
+ `<div><div>1</div></div><div><div>1</div></div><p>2</p><p>3</p>`
586
+ )
587
+
588
+ // move the <p>3</p> into the <div>1</div>
589
+ rerender (
590
+ appId ,
591
+ compileToFunction (
592
+ `<div v-for="item of 2"><div>1<p>3</p></div></div><p>2</p>`
593
+ )
594
+ )
595
+ expect ( serializeInner ( root ) ) . toBe (
596
+ `<div><div>1<p>3</p></div></div><div><div>1<p>3</p></div></div><p>2</p>`
597
+ )
598
+ } )
571
599
} )
0 commit comments