2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-19 23:10:34 +03:00

fix: use undefined as child ignore indicator

This commit is contained in:
pimlie
2019-03-08 15:54:17 +01:00
committed by Alexander Lichter
parent 915fedfb7f
commit 104113a7b8
2 changed files with 8 additions and 5 deletions
+6 -3
View File
@@ -20,7 +20,10 @@ export function arrayMerge({ component, tagIDKeyName, metaTemplateKeyName, conte
// source doesnt contain any duplicate id's
// or the source item should be ignored
if (sourceIndex === -1 || sourceItem[contentKeyName] === false || sourceItem.innerHTML === false) {
if (sourceIndex === -1 ||
(sourceItem.hasOwnProperty(contentKeyName) && sourceItem[contentKeyName] === undefined) ||
(sourceItem.hasOwnProperty('innerHTML') && sourceItem.innerHTML === undefined)
) {
destination.push(targetItem)
return
}
@@ -57,7 +60,7 @@ export function merge(target, source, options = {}) {
// remove properties explicitly set to false so child components can
// optionally _not_ overwrite the parents content
// (for array properties this is checked in arrayMerge)
if (source.title === false) {
if (source.hasOwnProperty('title') && source.title === undefined) {
delete source.title
}
@@ -67,7 +70,7 @@ export function merge(target, source, options = {}) {
}
for (const key in source[attrKey]) {
if (source[attrKey][key] === false) {
if (source[attrKey].hasOwnProperty(key) && source[attrKey][key] === undefined) {
delete source[attrKey][key]
}
}
+2 -2
View File
@@ -622,11 +622,11 @@ describe('getMetaInfo', () => {
Vue.component('merge-child', {
render: h => h('div'),
metaInfo: {
title: false,
title: undefined,
meta: [
{
vmid: 'og:title',
content: false
content: undefined
}
]
}