Use getElementsByClassName

This commit is contained in:
Eduard Urbach 2017-06-21 15:29:06 +02:00
parent cc09017b36
commit 9bd5e71205
2 changed files with 5 additions and 5 deletions

View File

@ -32,7 +32,7 @@ export class AnimeNotifier {
}
updateActions() {
for(let element of findAll(".action")) {
for(let element of findAll("action")) {
let actionName = element.dataset.action
element.addEventListener(element.dataset.trigger, e => {
@ -44,7 +44,7 @@ export class AnimeNotifier {
}
updateAvatars() {
for(let element of findAll(".user-image")) {
for(let element of findAll("user-image")) {
let img = element as HTMLImageElement
if(img.naturalWidth === 0) {
@ -67,7 +67,7 @@ export class AnimeNotifier {
let time = 0
for(let element of findAll(".mountable")) {
for(let element of findAll("mountable")) {
setTimeout(() => {
window.requestAnimationFrame(() => element.classList.add("mounted"))
}, time)

View File

@ -1,5 +1,5 @@
export function* findAll(query: string) {
let elements = document.querySelectorAll(query)
export function* findAll(className: string) {
let elements = document.getElementsByClassName(className)
for(let i = 0; i < elements.length; ++i) {
yield elements[i] as HTMLElement