Skip to content
This repository was archived by the owner on Oct 1, 2025. It is now read-only.

Commit b1f83f9

Browse files
author
Sebastien Chopin
committed
Fix beforeMount & destroyed hooks
1 parent 29df47b commit b1f83f9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/shared/plugin.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ export default function VueMeta (Vue, options = {}) {
3838
// watch for client side component updates
3939
Vue.mixin({
4040
beforeCreate () {
41+
// Add a marker to know if it uses metaInfo
42+
if (typeof this.$options[options.keyName] !== 'undefined') {
43+
this._hasMetaInfo = true
44+
}
4145
// coerce function-style metaInfo to a computed prop so we can observe
4246
// it on creation
4347
if (typeof this.$options[options.keyName] === 'function') {
@@ -60,15 +64,15 @@ export default function VueMeta (Vue, options = {}) {
6064
},
6165
beforeMount () {
6266
// batch potential DOM updates to prevent extraneous re-rendering
63-
if (this.$metaInfo) {
67+
if (this._hasMetaInfo) {
6468
batchID = batchUpdate(batchID, () => this.$meta().refresh())
6569
}
6670
},
6771
destroyed () {
6872
// do not trigger refresh on the server side
6973
if (this.$isServer) return
7074
// re-render meta data when returning from a child component to parent
71-
if (this.$metaInfo) {
75+
if (this._hasMetaInfo) {
7276
batchID = batchUpdate(batchID, () => this.$meta().refresh())
7377
}
7478
}

0 commit comments

Comments
 (0)