improve perf of hydrateContent slightly
This commit is contained in:
parent
fc8554bed3
commit
8c8c6bab25
|
@ -95,13 +95,13 @@
|
||||||
if (!this.refs.node) {
|
if (!this.refs.node) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
let node = this.refs.node
|
||||||
let status = this.get('status')
|
let status = this.get('status')
|
||||||
let statusId = this.get('statusId')
|
let statusId = this.get('statusId')
|
||||||
let count = 0
|
let count = 0
|
||||||
mark('hydrateContent')
|
mark('hydrateContent')
|
||||||
if (status.tags && status.tags.length) {
|
if (status.tags && status.tags.length) {
|
||||||
let anchorTags = Array.from(this.refs.node.querySelectorAll(
|
let anchorTags = node.querySelectorAll('a[class~=hashtag][href^=http]')
|
||||||
'a[class~=hashtag][href^=http]'))
|
|
||||||
for (let tag of status.tags) {
|
for (let tag of status.tags) {
|
||||||
for (let anchorTag of anchorTags) {
|
for (let anchorTag of anchorTags) {
|
||||||
if (anchorTag.getAttribute('href').endsWith(`/tags/${tag.name}`)) {
|
if (anchorTag.getAttribute('href').endsWith(`/tags/${tag.name}`)) {
|
||||||
|
@ -114,8 +114,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (status.mentions && status.mentions.length) {
|
if (status.mentions && status.mentions.length) {
|
||||||
let anchorTags = Array.from(this.refs.node.querySelectorAll(
|
let anchorTags = node.querySelectorAll('a[class~=mention][href^=http]')
|
||||||
'a[class~=mention][href^=http]'))
|
|
||||||
for (let mention of status.mentions) {
|
for (let mention of status.mentions) {
|
||||||
for (let anchorTag of anchorTags) {
|
for (let anchorTag of anchorTags) {
|
||||||
if (anchorTag.getAttribute('href') === mention.url) {
|
if (anchorTag.getAttribute('href') === mention.url) {
|
||||||
|
@ -127,8 +126,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let externalLinks = Array.from(this.refs.node.querySelectorAll(
|
let externalLinks = node.querySelectorAll('a[rel="nofollow noopener"]')
|
||||||
'a[rel="nofollow noopener"]'))
|
|
||||||
for (let link of externalLinks) {
|
for (let link of externalLinks) {
|
||||||
link.setAttribute('title', link.getAttribute('href'))
|
link.setAttribute('title', link.getAttribute('href'))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue