mirror of
https://github.com/tenrok/vue-meta.git
synced 2026-06-19 06:20:34 +03:00
fix: prefer for..in instead keys.forEach
This commit is contained in:
@@ -28,22 +28,22 @@ export default function updateClientMetaInfo(options = {}, newInfo) {
|
||||
const addedTags = {}
|
||||
const removedTags = {}
|
||||
|
||||
Object.keys(newInfo).forEach((type) => {
|
||||
for (const type in newInfo) {
|
||||
// ignore these
|
||||
if (metaInfoOptionKeys.includes(type)) {
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
if (type === 'title') {
|
||||
// update the title
|
||||
updateTitle(newInfo.title)
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
if (metaInfoAttributeKeys.includes(type)) {
|
||||
const tagName = type.substr(0, 4)
|
||||
updateAttribute(options, newInfo[type], getTag(tags, tagName))
|
||||
return
|
||||
continue
|
||||
}
|
||||
|
||||
const { oldTags, newTags } = updateTag(
|
||||
@@ -58,7 +58,7 @@ export default function updateClientMetaInfo(options = {}, newInfo) {
|
||||
addedTags[type] = newTags
|
||||
removedTags[type] = oldTags
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return { addedTags, removedTags }
|
||||
} else {
|
||||
|
||||
@@ -13,7 +13,9 @@ export default function tagGenerator({ attribute, tagIDKeyName } = {}, type, tag
|
||||
text({ body = false } = {}) {
|
||||
// build a string containing all tags of this type
|
||||
return tags.reduce((tagsStr, tag) => {
|
||||
if (Object.keys(tag).length === 0) {
|
||||
const tagKeys = Object.keys(tag)
|
||||
|
||||
if (tagKeys.length === 0) {
|
||||
return tagsStr // Bail on empty tag object
|
||||
}
|
||||
|
||||
@@ -22,7 +24,7 @@ export default function tagGenerator({ attribute, tagIDKeyName } = {}, type, tag
|
||||
}
|
||||
|
||||
// build a string containing all attributes of this tag
|
||||
const attrs = Object.keys(tag).reduce((attrsStr, attr) => {
|
||||
const attrs = tagKeys.reduce((attrsStr, attr) => {
|
||||
// these attributes are treated as children on the tag
|
||||
if (tagAttributeAsInnerContent.includes(attr) || attr === 'once') {
|
||||
return attrsStr
|
||||
|
||||
Reference in New Issue
Block a user