Skip to content

Commit 7615f41

Browse files
pimlieTheAlexLichter
authored andcommitted
fix: ignore data when its not an object (fixes: #253, #279, #297)
1 parent 23c3380 commit 7615f41

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

src/shared/getComponentOption.js

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ export default function getComponentOption(options = {}, result = {}) {
3636

3737
// ignore data if its not an object, then we keep our previous result
3838
if (!isObject(data)) {
39-
console.log(data)
4039
return result
4140
}
4241

test/getComponentOptions.test.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,23 @@ describe('getComponentOption', () => {
1313
})
1414

1515
it('fetches the given option from the given component', () => {
16-
const component = new Vue({ someOption: 'foo' })
16+
const component = new Vue({ someOption: { foo: 'bar' } })
1717
const mergedOption = getComponentOption({ component, keyName: 'someOption' })
18-
expect(mergedOption).toEqual('foo')
18+
expect(mergedOption.foo).toBeDefined()
19+
expect(mergedOption.foo).toEqual('bar')
1920
})
2021

2122
it('calls a function option, injecting the component as context', () => {
2223
const component = new Vue({
2324
name: 'Foobar',
2425
someFunc() {
25-
return this.$options.name
26+
return { opt: this.$options.name }
2627
}
2728
})
2829
const mergedOption = getComponentOption({ component, keyName: 'someFunc' })
2930
// TODO: Should this be foobar or Foobar
30-
expect(mergedOption).toEqual('Foobar')
31+
expect(mergedOption.opt).toBeDefined()
32+
expect(mergedOption.opt).toEqual('Foobar')
3133
})
3234

3335
it('fetches deeply nested component options and merges them', () => {

test/getMetaInfo.test.js

+26-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ describe('getMetaInfo', () => {
117117
{
118118
vmid: 'a',
119119
property: 'a',
120-
content: 'b'
120+
content: 'a'
121121
}
122122
],
123123
base: [],
@@ -592,4 +592,29 @@ describe('getMetaInfo', () => {
592592
__dangerouslyDisableSanitizersByTagID: {}
593593
})
594594
})
595+
596+
test('no errors when metaInfo returns nothing', () => {
597+
const component = new Vue({
598+
metaInfo() {},
599+
el: document.createElement('div'),
600+
render: h => h('div', null, [])
601+
})
602+
603+
expect(getMetaInfo(component)).toEqual({
604+
title: '',
605+
titleChunk: '',
606+
titleTemplate: '%s',
607+
htmlAttrs: {},
608+
headAttrs: {},
609+
bodyAttrs: {},
610+
meta: [],
611+
base: [],
612+
link: [],
613+
style: [],
614+
script: [],
615+
noscript: [],
616+
__dangerouslyDisableSanitizers: [],
617+
__dangerouslyDisableSanitizersByTagID: {}
618+
})
619+
})
595620
})

0 commit comments

Comments
 (0)