Skip to content

Commit

Permalink
fix: Handle body attribute with valid W3C HTML
Browse files Browse the repository at this point in the history
  • Loading branch information
Atinux committed Nov 6, 2017
1 parent 8ac7ecc commit 885a3f5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/client/updaters/updateTags.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/server/generators/tagGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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'
Expand Down
5 changes: 1 addition & 4 deletions src/shared/getComponentOption.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion src/shared/getMetaInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 885a3f5

Please sign in to comment.