mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-18 15:00:33 +03:00
switch to beforemount hook & improve test timing logic
This commit is contained in:
+2
-2
@@ -20,7 +20,7 @@ export default function VueMeta (Vue) {
|
||||
|
||||
// watch for client side component updates
|
||||
Vue.mixin({
|
||||
mounted () {
|
||||
beforeMount () {
|
||||
// batch potential DOM updates to prevent extraneous re-rendering
|
||||
window.cancelAnimationFrame(requestId)
|
||||
|
||||
@@ -28,7 +28,7 @@ export default function VueMeta (Vue) {
|
||||
requestId = null
|
||||
|
||||
// update the meta info
|
||||
updateClientMetaInfo(getMetaInfo(this.$root))
|
||||
updateClientMetaInfo(getMetaInfo(this.$root), this.$root)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
@@ -11,7 +11,7 @@ if (typeof window !== 'undefined' && window !== null) {
|
||||
*
|
||||
* @param {Object} newInfo - the meta info to update to
|
||||
*/
|
||||
export default function updateClientMetaInfo (newInfo) {
|
||||
export default function updateClientMetaInfo (newInfo, $root) {
|
||||
// if this is not a server render, then update
|
||||
if (htmlTag.getAttribute(SERVER_RENDERED_ATTRIBUTE) === null) {
|
||||
if (newInfo.title) {
|
||||
@@ -24,4 +24,9 @@ export default function updateClientMetaInfo (newInfo) {
|
||||
} else {
|
||||
htmlTag.removeAttribute(SERVER_RENDERED_ATTRIBUTE)
|
||||
}
|
||||
|
||||
// HACK: since we're performing DOM side effects, we can't rely on
|
||||
// Vue.nextTick in our tests. This event helps keep the test suite
|
||||
// free of setTimeout clutter
|
||||
$root.$emit('vue-meta-update')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user