@@ -9,8 +9,10 @@ export default function createMixin(options) {
9
9
const updateOnLifecycleHook = [ 'activated' , 'deactivated' , 'beforeMount' ]
10
10
11
11
const triggerUpdate = ( vm ) => {
12
- // batch potential DOM updates to prevent extraneous re-rendering
13
- batchID = batchUpdate ( batchID , ( ) => vm . $meta ( ) . refresh ( ) )
12
+ if ( vm . $root . _vueMetaInitialized ) {
13
+ // batch potential DOM updates to prevent extraneous re-rendering
14
+ batchID = batchUpdate ( batchID , ( ) => vm . $meta ( ) . refresh ( ) )
15
+ }
14
16
}
15
17
16
18
// watch for client side component updates
@@ -46,6 +48,24 @@ export default function createMixin(options) {
46
48
this . $options [ lifecycleHook ] . push ( ( ) => triggerUpdate ( this ) )
47
49
} )
48
50
51
+ // force an initial refresh on page load and prevent other lifecycleHooks
52
+ // to triggerUpdate until this initial refresh is finished
53
+ // this is to make sure that when a page is opened in an inactive tab which
54
+ // has throttled rAF/timers we still immeditately set the page title
55
+ if ( isUndefined ( this . $root . _vueMetaInitialized ) ) {
56
+ this . $root . _vueMetaInitialized = false
57
+
58
+ this . $root . $options . mounted = this . $root . $options . mounted || [ ]
59
+ this . $root . $options . mounted . push ( ( ) => {
60
+ if ( ! this . $root . _vueMetaInitialized ) {
61
+ this . $nextTick ( function ( ) {
62
+ this . $root . $meta ( ) . refresh ( )
63
+ this . $root . _vueMetaInitialized = true
64
+ } )
65
+ }
66
+ } )
67
+ }
68
+
49
69
// do not trigger refresh on the server side
50
70
if ( ! this . $isServer ) {
51
71
// re-render meta data when returning from a child component to parent
0 commit comments