Skip to content

Commit 6741897

Browse files
committed
fix: prefer for..in instead keys.forEach
1 parent 5031acf commit 6741897

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/client/updateClientMetaInfo.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ export default function updateClientMetaInfo(options = {}, newInfo) {
2828
const addedTags = {}
2929
const removedTags = {}
3030

31-
Object.keys(newInfo).forEach((type) => {
31+
for (const type in newInfo) {
3232
// ignore these
3333
if (metaInfoOptionKeys.includes(type)) {
34-
return
34+
continue
3535
}
3636

3737
if (type === 'title') {
3838
// update the title
3939
updateTitle(newInfo.title)
40-
return
40+
continue
4141
}
4242

4343
if (metaInfoAttributeKeys.includes(type)) {
4444
const tagName = type.substr(0, 4)
4545
updateAttribute(options, newInfo[type], getTag(tags, tagName))
46-
return
46+
continue
4747
}
4848

4949
const { oldTags, newTags } = updateTag(
@@ -58,7 +58,7 @@ export default function updateClientMetaInfo(options = {}, newInfo) {
5858
addedTags[type] = newTags
5959
removedTags[type] = oldTags
6060
}
61-
})
61+
}
6262

6363
return { addedTags, removedTags }
6464
} else {

src/server/generators/tag.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ export default function tagGenerator({ attribute, tagIDKeyName } = {}, type, tag
1313
text({ body = false } = {}) {
1414
// build a string containing all tags of this type
1515
return tags.reduce((tagsStr, tag) => {
16-
if (Object.keys(tag).length === 0) {
16+
const tagKeys = Object.keys(tag)
17+
18+
if (tagKeys.length === 0) {
1719
return tagsStr // Bail on empty tag object
1820
}
1921

@@ -22,7 +24,7 @@ export default function tagGenerator({ attribute, tagIDKeyName } = {}, type, tag
2224
}
2325

2426
// build a string containing all attributes of this tag
25-
const attrs = Object.keys(tag).reduce((attrsStr, attr) => {
27+
const attrs = tagKeys.reduce((attrsStr, attr) => {
2628
// these attributes are treated as children on the tag
2729
if (tagAttributeAsInnerContent.includes(attr) || attr === 'once') {
2830
return attrsStr

0 commit comments

Comments
 (0)