2
0
mirror of https://github.com/tenrok/vue-meta.git synced 2026-06-11 21:12:25 +03:00

fix: Handle body attribute with valid W3C HTML

This commit is contained in:
Atinux
2017-11-06 12:32:43 +01:00
parent 8ac7ecccaa
commit 885a3f5fdf
4 changed files with 6 additions and 9 deletions
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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'
+1 -4
View File
@@ -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
}
+1 -1
View File
@@ -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