diff --git a/examples/index.html b/examples/index.html index 54711b6..5c96d83 100644 --- a/examples/index.html +++ b/examples/index.html @@ -9,6 +9,7 @@
Foo component
', + metaInfo: { + title: 'Keep me Foo' + } +}) + +new Vue({ + template: ` +Inspect Element to see the meta info
` diff --git a/examples/vue-router/index.html b/examples/vue-router/index.html index cf41105..7ae5a53 100644 --- a/examples/vue-router/index.html +++ b/examples/vue-router/index.html @@ -3,3 +3,11 @@ ← Examples index + diff --git a/src/shared/getComponentOption.js b/src/shared/getComponentOption.js index 58e2405..cd5f644 100644 --- a/src/shared/getComponentOption.js +++ b/src/shared/getComponentOption.js @@ -18,6 +18,8 @@ export default function getComponentOption (opts, result = {}) { const { component, option, deep, arrayMerge } = opts const { $options } = component + if (component._inactive) return result + // only collect option data if it exists if (typeof $options[option] !== 'undefined' && $options[option] !== null) { let data = $options[option] diff --git a/src/shared/plugin.js b/src/shared/plugin.js index c275bc0..4f321cb 100644 --- a/src/shared/plugin.js +++ b/src/shared/plugin.js @@ -62,6 +62,18 @@ export default function VueMeta (Vue, options = {}) { }) } }, + activated () { + if (this._hasMetaInfo) { + // batch potential DOM updates to prevent extraneous re-rendering + batchID = batchUpdate(batchID, () => this.$meta().refresh()) + } + }, + deactivated () { + if (this._hasMetaInfo) { + // batch potential DOM updates to prevent extraneous re-rendering + batchID = batchUpdate(batchID, () => this.$meta().refresh()) + } + }, beforeMount () { // batch potential DOM updates to prevent extraneous re-rendering if (this._hasMetaInfo) { @@ -73,7 +85,12 @@ export default function VueMeta (Vue, options = {}) { if (this.$isServer) return // re-render meta data when returning from a child component to parent if (this._hasMetaInfo) { - batchID = batchUpdate(batchID, () => this.$meta().refresh()) + // Wait that element is hidden before refreshing meta tags (to support animations) + const interval = setInterval(() => { + if (this.$el.offsetParent !== null) return + clearInterval(interval) + batchID = batchUpdate(batchID, () => this.$meta().refresh()) + }, 50) } } })