2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-14 17:02:24 +03:00

Merge pull request #196 from eddiesigner/master

Clear Interval if the component doesn't have the $el property
This commit is contained in:
Sébastien Chopin
2018-03-13 17:46:18 +01:00
committed by GitHub
2 changed files with 34 additions and 1 deletions
+1 -1
View File
@@ -87,7 +87,7 @@ export default function VueMeta (Vue, options = {}) {
if (this._hasMetaInfo) {
// Wait that element is hidden before refreshing meta tags (to support animations)
const interval = setInterval(() => {
if (this.$el.offsetParent !== null) return
if (this.$el && this.$el.offsetParent !== null) return
clearInterval(interval)
batchID = batchUpdate(batchID, () => this.$meta().refresh())
}, 50)
+33
View File
@@ -0,0 +1,33 @@
import Vue from 'vue'
import VueMeta from '../src/shared/plugin'
import {
VUE_META_KEY_NAME,
VUE_META_ATTRIBUTE,
VUE_META_SERVER_RENDERED_ATTRIBUTE,
VUE_META_TAG_LIST_ID_KEY_NAME
} from '../src/shared/constants'
describe('plugin', () => {
Vue.use(VueMeta, {
keyName: VUE_META_KEY_NAME,
attribute: VUE_META_ATTRIBUTE,
ssrAttribute: VUE_META_SERVER_RENDERED_ATTRIBUTE,
tagIDKeyName: VUE_META_TAG_LIST_ID_KEY_NAME
})
it('adds $meta() to Vue prototype', () => {
const instance = new Vue()
expect(instance.$meta).to.be.a('function')
})
it('components have _hasMetaInfo set to true', () => {
const Component = Vue.component('test-component', {
template: '<div>Test</div>',
[VUE_META_KEY_NAME]: {
title: 'helloworld'
}
})
const vm = new Vue(Component).$mount()
expect(vm._hasMetaInfo).to.equal(true)
})
})