@@ -25,9 +25,28 @@ export function createRenderFunction (
2525 isRoot : boolean
2626 ) {
2727 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 ( )
3150 child . parent = node
3251 renderNode ( child , write , next , isRoot )
3352 } else {
@@ -39,21 +58,6 @@ export function createRenderFunction (
3958 }
4059 }
4160
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-
5761 function renderElement (
5862 el : VNode ,
5963 write : Function ,
@@ -94,9 +98,6 @@ export function createRenderFunction (
9498 }
9599
96100 function renderStartingTag ( node : VNode ) {
97- if ( node . _rendered ) {
98- return node . _rendered
99- }
100101 let markup = `<${ node . tag } `
101102 if ( node . data ) {
102103 // check directives
@@ -124,14 +125,13 @@ export function createRenderFunction (
124125 if ( node . host && ( scopeId = node . host . $options . _scopeId ) ) {
125126 markup += ` ${ scopeId } `
126127 }
127- let _node = node
128- while ( _node ) {
129- if ( ( scopeId = _node . context . $options . _scopeId ) ) {
128+ while ( node ) {
129+ if ( ( scopeId = node . context . $options . _scopeId ) ) {
130130 markup += ` ${ scopeId } `
131131 }
132- _node = _node . parent
132+ node = node . parent
133133 }
134- return ( node . _rendered = markup + '>' )
134+ return markup + '> '
135135 }
136136
137137 return function render (
0 commit comments