From 885a3f5fdf4913082b824cc4387fa56fc972dfc0 Mon Sep 17 00:00:00 2001 From: Atinux Date: Mon, 6 Nov 2017 12:32:43 +0100 Subject: [PATCH] fix: Handle body attribute with valid W3C HTML --- src/client/updaters/updateTags.js | 4 ++-- src/server/generators/tagGenerator.js | 4 ++-- src/shared/getComponentOption.js | 5 +---- src/shared/getMetaInfo.js | 2 +- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/client/updaters/updateTags.js b/src/client/updaters/updateTags.js index 3811457d..ae7e868d 100644 --- a/src/client/updaters/updateTags.js +++ b/src/client/updaters/updateTags.js @@ -47,7 +47,7 @@ export default function _updateTags (options = {}) { } else { newElement.appendChild(document.createTextNode(tag.cssText)) } - } else if (attr === options.tagIDKeyName) { + } else if ([options.tagIDKeyName, 'body'].includes(attr)) { const _attr = `data-${attr}` const value = (typeof tag[attr] === 'undefined') ? '' : tag[attr] newElement.setAttribute(_attr, value) @@ -74,7 +74,7 @@ export default function _updateTags (options = {}) { const oldTags = oldHeadTags.concat(oldBodyTags) oldTags.forEach((tag) => tag.parentNode.removeChild(tag)) newTags.forEach((tag) => { - if (tag.getAttribute('body') === 'true') { + if (tag.getAttribute('data-body') === 'true') { bodyTag.appendChild(tag) } else { headTag.appendChild(tag) diff --git a/src/server/generators/tagGenerator.js b/src/server/generators/tagGenerator.js index e0de352c..30fc0573 100644 --- a/src/server/generators/tagGenerator.js +++ b/src/server/generators/tagGenerator.js @@ -10,7 +10,7 @@ export default function _tagGenerator (options = {}) { */ return function tagGenerator (type, tags) { return { - text ({body = false} = {}) { + text ({ body = false } = {}) { // build a string containing all tags of this type return tags.reduce((tagsStr, tag) => { if (!!tag.body !== body) return tagsStr @@ -24,7 +24,7 @@ export default function _tagGenerator (options = {}) { return attrsStr // these form the attribute list for this tag default: - if (attr === options.tagIDKeyName) { + if ([options.tagIDKeyName, 'body'].includes(attr)) { return `${attrsStr} data-${attr}="${tag[attr]}"` } return typeof tag[attr] === 'undefined' diff --git a/src/shared/getComponentOption.js b/src/shared/getComponentOption.js index cd5f644d..37d31932 100644 --- a/src/shared/getComponentOption.js +++ b/src/shared/getComponentOption.js @@ -31,10 +31,7 @@ export default function getComponentOption (opts, result = {}) { if (typeof data === 'object') { // merge with existing options - result = deepmerge(result, data, { - clone: true, - arrayMerge - }) + result = deepmerge(result, data, { arrayMerge }) } else { result = data } diff --git a/src/shared/getMetaInfo.js b/src/shared/getMetaInfo.js index 92613b0a..119c3bd8 100644 --- a/src/shared/getMetaInfo.js +++ b/src/shared/getMetaInfo.js @@ -52,7 +52,7 @@ export default function _getMetaInfo (options = {}) { option: keyName, deep: true, arrayMerge (target, source) { - // we concat the arrays without merging objects contained therein, + // we concat the arrays without merging objects contained in, // but we check for a `vmid` property on each object in the array // using an O(1) lookup associative array exploit // note the use of "for in" - we are looping through arrays here, not