Skip to content

Commit

Permalink
fix: use undefined as child ignore indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
pimlie authored and manniL committed Mar 12, 2019
1 parent 915fedf commit 104113a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions src/shared/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand All @@ -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]
}
}
Expand Down
4 changes: 2 additions & 2 deletions test/getMetaInfo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
Expand Down

0 comments on commit 104113a

Please sign in to comment.