use regular for loop for html dom element collection

This commit is contained in:
Nolan Lawson 2018-04-04 18:34:43 -07:00
parent eac398702d
commit cbe7192928
1 changed files with 6 additions and 3 deletions

View File

@ -102,7 +102,8 @@
if (originalStatus.tags && originalStatus.tags.length) { if (originalStatus.tags && originalStatus.tags.length) {
let anchorTags = node.querySelectorAll('a[class~=hashtag][href^=http]') let anchorTags = node.querySelectorAll('a[class~=hashtag][href^=http]')
for (let tag of originalStatus.tags) { for (let tag of originalStatus.tags) {
for (let anchorTag of anchorTags) { for (let i = 0, len = anchorTags.length; i < len; i++) {
let anchorTag = anchorTags[i]
if (anchorTag.getAttribute('href').endsWith(`/tags/${tag.name}`)) { if (anchorTag.getAttribute('href').endsWith(`/tags/${tag.name}`)) {
anchorTag.setAttribute('href', `/tags/${tag.name}`) anchorTag.setAttribute('href', `/tags/${tag.name}`)
anchorTag.setAttribute('focus-key', `status-content-link-${uuid}-${++count}`) anchorTag.setAttribute('focus-key', `status-content-link-${uuid}-${++count}`)
@ -115,7 +116,8 @@
if (originalStatus.mentions && originalStatus.mentions.length) { if (originalStatus.mentions && originalStatus.mentions.length) {
let anchorTags = node.querySelectorAll('a[class~=mention][href^=http]') let anchorTags = node.querySelectorAll('a[class~=mention][href^=http]')
for (let mention of originalStatus.mentions) { for (let mention of originalStatus.mentions) {
for (let anchorTag of anchorTags) { for (let i = 0, len = anchorTags.length; i < len; i++) {
let anchorTag = anchorTags[i]
if (anchorTag.getAttribute('href') === mention.url) { if (anchorTag.getAttribute('href') === mention.url) {
anchorTag.setAttribute('href', `/accounts/${mention.id}`) anchorTag.setAttribute('href', `/accounts/${mention.id}`)
anchorTag.setAttribute('title', `@${mention.acct}`) anchorTag.setAttribute('title', `@${mention.acct}`)
@ -127,7 +129,8 @@
} }
} }
let externalLinks = node.querySelectorAll('a[rel="nofollow noopener"]') let externalLinks = node.querySelectorAll('a[rel="nofollow noopener"]')
for (let link of externalLinks) { for (let i = 0, len = externalLinks.length; i < len; i++) {
let link = externalLinks[i]
link.setAttribute('title', link.getAttribute('href')) link.setAttribute('title', link.getAttribute('href'))
} }
stop('hydrateContent') stop('hydrateContent')