2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-25 01:40:33 +03:00

fix: another inline array to const

This commit is contained in:
pimlie
2019-02-10 23:57:31 +01:00
parent 48061ba39c
commit 78f2c46c20
+4 -1
View File
@@ -44,6 +44,9 @@ export default function VueMeta(Vue, options = {}) {
// store an id to keep track of DOM updates // store an id to keep track of DOM updates
let batchID = null let batchID = null
// for which Vue lifecycle hooks should the metaInfo be refreshed
const updateOnLifecycleHook = ['activated', 'deactivated', 'beforeMount']
const triggerUpdate = (vm) => { const triggerUpdate = (vm) => {
// batch potential DOM updates to prevent extraneous re-rendering // batch potential DOM updates to prevent extraneous re-rendering
batchID = batchUpdate(batchID, () => vm.$meta().refresh()) batchID = batchUpdate(batchID, () => vm.$meta().refresh())
@@ -77,7 +80,7 @@ export default function VueMeta(Vue, options = {}) {
} }
} }
['activated', 'deactivated', 'beforeMount'].forEach((lifecycleHook) => { updateOnLifecycleHook.forEach((lifecycleHook) => {
this.$options[lifecycleHook] = this.$options[lifecycleHook] || [] this.$options[lifecycleHook] = this.$options[lifecycleHook] || []
this.$options[lifecycleHook].push(() => triggerUpdate(this)) this.$options[lifecycleHook].push(() => triggerUpdate(this))
}) })