Use const variables when applicable
This commit is contained in:
@ -14,10 +14,10 @@ export default class SVGIcon extends HTMLElement {
|
||||
}
|
||||
|
||||
async render() {
|
||||
let cache = SVGIcon.cache.get(this.name)
|
||||
const cache = SVGIcon.cache.get(this.name)
|
||||
|
||||
if(cache) {
|
||||
let svg = await cache
|
||||
const svg = await cache
|
||||
|
||||
Diff.mutations.queue(() => {
|
||||
// Remove all existing child nodes
|
||||
@ -33,8 +33,8 @@ export default class SVGIcon extends HTMLElement {
|
||||
}
|
||||
|
||||
SVGIcon.cache.set(this.name, new Promise(async (resolve, reject) => {
|
||||
let url = `//media.notify.moe/images/icons/${this.name}.svg`
|
||||
let response = await fetch(url)
|
||||
const url = `//media.notify.moe/images/icons/${this.name}.svg`
|
||||
const response = await fetch(url)
|
||||
|
||||
if(!response.ok) {
|
||||
console.warn(`Failed loading SVG icon: ${url}`)
|
||||
@ -42,11 +42,11 @@ export default class SVGIcon extends HTMLElement {
|
||||
return
|
||||
}
|
||||
|
||||
let text = await response.text()
|
||||
const text = await response.text()
|
||||
|
||||
Diff.mutations.queue(() => {
|
||||
this.innerHTML = text
|
||||
let svg = this.firstChild
|
||||
const svg = this.firstChild
|
||||
|
||||
if(!svg) {
|
||||
console.warn("Invalid SVG icon:", svg)
|
||||
|
@ -25,13 +25,13 @@ export default class ToolTip extends HTMLElement {
|
||||
this.anchor = anchor
|
||||
this.box.textContent = this.anchor.getAttribute("aria-label")
|
||||
|
||||
let anchorRect = this.anchor.getBoundingClientRect()
|
||||
let boxRect = this.box.getBoundingClientRect()
|
||||
const anchorRect = this.anchor.getBoundingClientRect()
|
||||
const boxRect = this.box.getBoundingClientRect()
|
||||
|
||||
let finalX = anchorRect.left + anchorRect.width / 2 - boxRect.width / 2
|
||||
let finalY = anchorRect.top - boxRect.height
|
||||
|
||||
let contentRect = {
|
||||
const contentRect = {
|
||||
left: distanceToBorder,
|
||||
top: distanceToBorder,
|
||||
right: document.body.clientWidth - distanceToBorder,
|
||||
@ -54,7 +54,7 @@ export default class ToolTip extends HTMLElement {
|
||||
finalY += offsetY
|
||||
}
|
||||
|
||||
let arrowX = boxRect.width / 2 - offsetX
|
||||
const arrowX = boxRect.width / 2 - offsetX
|
||||
|
||||
Diff.mutations.queue(() => {
|
||||
this.style.left = finalX + "px"
|
||||
|
Reference in New Issue
Block a user