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:
committed by
Alexander Lichter
parent
915fedfb7f
commit
104113a7b8
+6
-3
@@ -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]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user