@@ -57,22 +57,26 @@ function renderNode (node, isRoot, context) {
5757 }
5858}
5959
60+ function registerComponentForCache ( options , write ) {
61+ // exposed by vue-loader, need to call this if cache hit because
62+ // component lifecycle hooks will not be called.
63+ const register = options . _ssrRegister
64+ if ( write . caching && isDef ( register ) ) {
65+ write . componentBuffer [ write . componentBuffer . length - 1 ] . add ( register )
66+ }
67+ return register
68+ }
69+
6070function renderComponent ( node , isRoot , context ) {
6171 const { write, next, userContext } = context
6272
6373 // check cache hit
6474 const Ctor = node . componentOptions . Ctor
6575 const getKey = Ctor . options . serverCacheKey
6676 const name = Ctor . options . name
67-
68- // exposed by vue-loader, need to call this if cache hit because
69- // component lifecycle hooks will not be called.
70- const registerComponent = Ctor . options . _ssrRegister
71- if ( write . caching && isDef ( registerComponent ) ) {
72- write . componentBuffer [ write . componentBuffer . length - 1 ] . add ( registerComponent )
73- }
74-
7577 const cache = context . cache
78+ const registerComponent = registerComponentForCache ( Ctor . options , write )
79+
7680 if ( isDef ( getKey ) && isDef ( cache ) && isDef ( name ) ) {
7781 const key = name + '::' + getKey ( node . componentOptions . propsData )
7882 const { has, get } = context
@@ -147,7 +151,6 @@ function renderComponentInner (node, isRoot, context) {
147151 node ,
148152 context . activeInstance
149153 )
150- node . ssrContext = null
151154 normalizeRender ( child )
152155 const childNode = child . _render ( )
153156 childNode . parent = node
@@ -159,14 +162,20 @@ function renderComponentInner (node, isRoot, context) {
159162}
160163
161164function renderElement ( el , isRoot , context ) {
165+ const { write, next } = context
166+
162167 if ( isTrue ( isRoot ) ) {
163168 if ( ! el . data ) el . data = { }
164169 if ( ! el . data . attrs ) el . data . attrs = { }
165170 el . data . attrs [ SSR_ATTR ] = 'true'
166171 }
172+
173+ if ( el . functionalOptions ) {
174+ registerComponentForCache ( el . functionalOptions , write )
175+ }
176+
167177 const startTag = renderStartingTag ( el , context )
168178 const endTag = `</${ el . tag } >`
169- const { write, next } = context
170179 if ( context . isUnaryTag ( el . tag ) ) {
171180 write ( startTag , next )
172181 } else if ( isUndef ( el . children ) || el . children . length === 0 ) {
0 commit comments