@@ -57,22 +57,26 @@ function renderNode (node, isRoot, context) {
57
57
}
58
58
}
59
59
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
+
60
70
function renderComponent ( node , isRoot , context ) {
61
71
const { write, next, userContext } = context
62
72
63
73
// check cache hit
64
74
const Ctor = node . componentOptions . Ctor
65
75
const getKey = Ctor . options . serverCacheKey
66
76
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
-
75
77
const cache = context . cache
78
+ const registerComponent = registerComponentForCache ( Ctor . options , write )
79
+
76
80
if ( isDef ( getKey ) && isDef ( cache ) && isDef ( name ) ) {
77
81
const key = name + '::' + getKey ( node . componentOptions . propsData )
78
82
const { has, get } = context
@@ -147,7 +151,6 @@ function renderComponentInner (node, isRoot, context) {
147
151
node ,
148
152
context . activeInstance
149
153
)
150
- node . ssrContext = null
151
154
normalizeRender ( child )
152
155
const childNode = child . _render ( )
153
156
childNode . parent = node
@@ -159,14 +162,20 @@ function renderComponentInner (node, isRoot, context) {
159
162
}
160
163
161
164
function renderElement ( el , isRoot , context ) {
165
+ const { write, next } = context
166
+
162
167
if ( isTrue ( isRoot ) ) {
163
168
if ( ! el . data ) el . data = { }
164
169
if ( ! el . data . attrs ) el . data . attrs = { }
165
170
el . data . attrs [ SSR_ATTR ] = 'true'
166
171
}
172
+
173
+ if ( el . functionalOptions ) {
174
+ registerComponentForCache ( el . functionalOptions , write )
175
+ }
176
+
167
177
const startTag = renderStartingTag ( el , context )
168
178
const endTag = `</${ el . tag } >`
169
- const { write, next } = context
170
179
if ( context . isUnaryTag ( el . tag ) ) {
171
180
write ( startTag , next )
172
181
} else if ( isUndef ( el . children ) || el . children . length === 0 ) {
0 commit comments