@@ -11,6 +11,7 @@ let appId = 1
11
11
export default function createMixin ( Vue , options ) {
12
12
// for which Vue lifecycle hooks should the metaInfo be refreshed
13
13
const updateOnLifecycleHook = [ 'activated' , 'deactivated' , 'beforeMount' ]
14
+ let wasServerRendered = false
14
15
15
16
// watch for client side component updates
16
17
return {
@@ -20,6 +21,12 @@ export default function createMixin (Vue, options) {
20
21
const $options = this . $options
21
22
const devtoolsEnabled = Vue . config . devtools
22
23
24
+ if ( this === $root ) {
25
+ this . $on ( 'hook:beforeMount' , function ( ) {
26
+ wasServerRendered = this . $el && this . $el . nodeType === 1 && this . $el . hasAttribute ( 'data-server-rendered' )
27
+ } )
28
+ }
29
+
23
30
Object . defineProperty ( this , '_hasMetaInfo' , {
24
31
configurable : true ,
25
32
get ( ) {
@@ -99,10 +106,10 @@ export default function createMixin (Vue, options) {
99
106
$root [ rootConfigKey ] . initializedSsr = true
100
107
101
108
this . $on ( 'hook:beforeMount' , function ( ) {
102
- const $root = this
109
+ const $root = this [ rootKey ]
103
110
// if this Vue-app was server rendered, set the appId to 'ssr'
104
111
// only one SSR app per page is supported
105
- if ( $root . $el && $root . $el . nodeType === 1 && $root . $el . hasAttribute ( 'data-server-rendered' ) ) {
112
+ if ( wasServerRendered ) {
106
113
$root [ rootConfigKey ] . appId = options . ssrAppId
107
114
}
108
115
} )
0 commit comments