Skip to content

Commit 51ccf9e

Browse files
authored
Merge pull request #196 from eddiesigner/master
Clear Interval if the component doesn't have the $el property
2 parents 776ddf6 + 3e521cb commit 51ccf9e

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-1
lines changed

src/shared/plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default function VueMeta (Vue, options = {}) {
8787
if (this._hasMetaInfo) {
8888
// Wait that element is hidden before refreshing meta tags (to support animations)
8989
const interval = setInterval(() => {
90-
if (this.$el.offsetParent !== null) return
90+
if (this.$el && this.$el.offsetParent !== null) return
9191
clearInterval(interval)
9292
batchID = batchUpdate(batchID, () => this.$meta().refresh())
9393
}, 50)

test/plugin.spec.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import Vue from 'vue'
2+
import VueMeta from '../src/shared/plugin'
3+
import {
4+
VUE_META_KEY_NAME,
5+
VUE_META_ATTRIBUTE,
6+
VUE_META_SERVER_RENDERED_ATTRIBUTE,
7+
VUE_META_TAG_LIST_ID_KEY_NAME
8+
} from '../src/shared/constants'
9+
10+
describe('plugin', () => {
11+
Vue.use(VueMeta, {
12+
keyName: VUE_META_KEY_NAME,
13+
attribute: VUE_META_ATTRIBUTE,
14+
ssrAttribute: VUE_META_SERVER_RENDERED_ATTRIBUTE,
15+
tagIDKeyName: VUE_META_TAG_LIST_ID_KEY_NAME
16+
})
17+
18+
it('adds $meta() to Vue prototype', () => {
19+
const instance = new Vue()
20+
expect(instance.$meta).to.be.a('function')
21+
})
22+
23+
it('components have _hasMetaInfo set to true', () => {
24+
const Component = Vue.component('test-component', {
25+
template: '<div>Test</div>',
26+
[VUE_META_KEY_NAME]: {
27+
title: 'helloworld'
28+
}
29+
})
30+
const vm = new Vue(Component).$mount()
31+
expect(vm._hasMetaInfo).to.equal(true)
32+
})
33+
})

0 commit comments

Comments
 (0)