@@ -25,9 +25,28 @@ export function createRenderFunction (
25
25
isRoot : boolean
26
26
) {
27
27
if ( node . componentOptions ) {
28
- const child =
29
- getCachedComponent ( node ) ||
30
- createComponentInstanceForVnode ( node ) . _render ( )
28
+ // check cache hit
29
+ const Ctor = node . componentOptions . Ctor
30
+ const getKey = Ctor . options . server && Ctor . options . server . getCacheKey
31
+ if ( getKey ) {
32
+ const key = Ctor . cid + '::' + getKey ( node . componentOptions . propsData )
33
+ if ( cache . has ( key ) ) {
34
+ return write ( cache . get ( key ) , next )
35
+ } else {
36
+ if ( ! write . caching ) {
37
+ // initialize if not already caching
38
+ write . caching = true
39
+ const _next = next
40
+ next = ( ) => {
41
+ cache . set ( key , write . buffer )
42
+ write . caching = false
43
+ write . buffer = ''
44
+ _next ( )
45
+ }
46
+ }
47
+ }
48
+ }
49
+ const child = createComponentInstanceForVnode ( node ) . _render ( )
31
50
child . parent = node
32
51
renderNode ( child , write , next , isRoot )
33
52
} else {
@@ -39,21 +58,6 @@ export function createRenderFunction (
39
58
}
40
59
}
41
60
42
- function getCachedComponent ( node ) {
43
- const Ctor = node . componentOptions . Ctor
44
- const getKey = Ctor . options . server && Ctor . options . server . getCacheKey
45
- if ( getKey ) {
46
- const key = Ctor . cid + '::' + getKey ( node . componentOptions . propsData )
47
- if ( cache . has ( key ) ) {
48
- return cache . get ( key )
49
- } else {
50
- const res = createComponentInstanceForVnode ( node ) . _render ( )
51
- cache . set ( key , res )
52
- return res
53
- }
54
- }
55
- }
56
-
57
61
function renderElement (
58
62
el : VNode ,
59
63
write : Function ,
@@ -94,9 +98,6 @@ export function createRenderFunction (
94
98
}
95
99
96
100
function renderStartingTag ( node : VNode ) {
97
- if ( node . _rendered ) {
98
- return node . _rendered
99
- }
100
101
let markup = `<${ node . tag } `
101
102
if ( node . data ) {
102
103
// check directives
@@ -124,14 +125,13 @@ export function createRenderFunction (
124
125
if ( node . host && ( scopeId = node . host . $options . _scopeId ) ) {
125
126
markup += ` ${ scopeId } `
126
127
}
127
- let _node = node
128
- while ( _node ) {
129
- if ( ( scopeId = _node . context . $options . _scopeId ) ) {
128
+ while ( node ) {
129
+ if ( ( scopeId = node . context . $options . _scopeId ) ) {
130
130
markup += ` ${ scopeId } `
131
131
}
132
- _node = _node . parent
132
+ node = node . parent
133
133
}
134
- return ( node . _rendered = markup + '>' )
134
+ return markup + '> '
135
135
}
136
136
137
137
return function render (
0 commit comments