mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-24 10:50:34 +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:
@@ -87,7 +87,7 @@ export default function VueMeta (Vue, options = {}) {
|
|||||||
if (this._hasMetaInfo) {
|
if (this._hasMetaInfo) {
|
||||||
// Wait that element is hidden before refreshing meta tags (to support animations)
|
// Wait that element is hidden before refreshing meta tags (to support animations)
|
||||||
const interval = setInterval(() => {
|
const interval = setInterval(() => {
|
||||||
if (this.$el.offsetParent !== null) return
|
if (this.$el && this.$el.offsetParent !== null) return
|
||||||
clearInterval(interval)
|
clearInterval(interval)
|
||||||
batchID = batchUpdate(batchID, () => this.$meta().refresh())
|
batchID = batchUpdate(batchID, () => this.$meta().refresh())
|
||||||
}, 50)
|
}, 50)
|
||||||
|
|||||||
@@ -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)
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user