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