File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ export function renderMixin (Vue: Class<Component>) {
102
102
) : VNode | Array < VNode > {
103
103
let tree = this . _staticTrees [ index ]
104
104
// if has already-rendered static tree and not inside v-for,
105
- // we can reuse the same tree by indentity .
105
+ // we can reuse the same tree by doing a shallow clone .
106
106
if ( tree && ! isInFor ) {
107
107
return Array . isArray ( tree )
108
108
? cloneVNodes ( tree )
Original file line number Diff line number Diff line change @@ -329,7 +329,14 @@ export function createPatchFunction (backend) {
329
329
if ( oldVnode === vnode ) {
330
330
return
331
331
}
332
- if ( vnode . isStatic && oldVnode . isStatic && vnode . key === oldVnode . key ) {
332
+ // reuse element for static trees.
333
+ // note we only do this if the vnode is cloned -
334
+ // if the new node is not cloned it means the render functions have been
335
+ // reset by the hot-reload-api and we need to a proper re-render.
336
+ if ( vnode . isStatic &&
337
+ oldVnode . isStatic &&
338
+ vnode . key === oldVnode . key &&
339
+ vnode . isCloned ) {
333
340
vnode . elm = oldVnode . elm
334
341
return
335
342
}
Original file line number Diff line number Diff line change @@ -12,10 +12,11 @@ export default class VNode {
12
12
componentOptions: VNodeComponentOptions | void ;
13
13
child: Component | void ; // component instance
14
14
parent: VNode | void ; // compoennt placeholder node
15
- raw: ? boolean ; // contains raw HTML? (server only)
16
- isStatic: ? boolean ; // hoisted static node
15
+ raw: boolean ; // contains raw HTML? (server only)
16
+ isStatic: boolean ; // hoisted static node
17
17
isRootInsert: boolean ; // necessary for enter transition check
18
- isComment: boolean ;
18
+ isComment: boolean ; // empty comment placeholder?
19
+ isCloned: boolean ; // is a cloned node?
19
20
20
21
constructor (
21
22
tag ? : string ,
@@ -42,6 +43,7 @@ export default class VNode {
42
43
this . isStatic = false
43
44
this . isRootInsert = true
44
45
this . isComment = false
46
+ this . isCloned = false
45
47
// apply construct hook.
46
48
// this is applied during render, before patch happens.
47
49
// unlike other hooks, this is applied on both client and server.
@@ -76,6 +78,7 @@ export function cloneVNode (vnode: VNode): VNode {
76
78
)
77
79
cloned . isStatic = vnode . isStatic
78
80
cloned . key = vnode . key
81
+ cloned . isCloned = true
79
82
return cloned
80
83
}
81
84
You can’t perform that action at this time.
0 commit comments