@@ -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
@@ -537,4 +537,32 @@ describe('hot module replacement', () => {
537
537
render ( h ( Foo ) , root )
538
538
expect ( serializeInner ( root ) ) . toBe ( 'bar' )
539
539
} )
540
+
541
+ test ( 'rerender in change hoisted nodes' , ( ) => {
542
+ const root = nodeOps . createElement ( 'div' )
543
+ const appId = 'test-app-id'
544
+ const App : ComponentOptions = {
545
+ __hmrId : appId ,
546
+ render : compileToFunction (
547
+ `<div v-for="item of 2"><div>1</div></div><p>2</p><p>3</p>`
548
+ )
549
+ }
550
+ createRecord ( appId , App )
551
+
552
+ render ( h ( App ) , root )
553
+ expect ( serializeInner ( root ) ) . toBe (
554
+ `<div><div>1</div></div><div><div>1</div></div><p>2</p><p>3</p>`
555
+ )
556
+
557
+ // move the <p>3</p> into the <div>1</div>
558
+ rerender (
559
+ appId ,
560
+ compileToFunction (
561
+ `<div v-for="item of 2"><div>1<p>3</p></div></div><p>2</p>`
562
+ )
563
+ )
564
+ expect ( serializeInner ( root ) ) . toBe (
565
+ `<div><div>1<p>3</p></div></div><div><div>1<p>3</p></div></div><p>2</p>`
566
+ )
567
+ } )
540
568
} )
0 commit comments