From 104113a7b80579e9d9cb1d959bbe19ac1913767b Mon Sep 17 00:00:00 2001 From: pimlie Date: Fri, 8 Mar 2019 15:54:17 +0100 Subject: [PATCH] fix: use undefined as child ignore indicator --- src/shared/merge.js | 9 ++++++--- test/getMetaInfo.test.js | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/shared/merge.js b/src/shared/merge.js index f0af9c35..00bc59bd 100644 --- a/src/shared/merge.js +++ b/src/shared/merge.js @@ -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] } } diff --git a/test/getMetaInfo.test.js b/test/getMetaInfo.test.js index b496e853..65152f92 100644 --- a/test/getMetaInfo.test.js +++ b/test/getMetaInfo.test.js @@ -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 } ] }