From 9bd5e71205084989b40482b07784003d326ca2fb Mon Sep 17 00:00:00 2001 From: Eduard Urbach Date: Wed, 21 Jun 2017 15:29:06 +0200 Subject: [PATCH] Use getElementsByClassName --- scripts/AnimeNotifier.ts | 6 +++--- scripts/utils.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/AnimeNotifier.ts b/scripts/AnimeNotifier.ts index c4b86407..82eed8af 100644 --- a/scripts/AnimeNotifier.ts +++ b/scripts/AnimeNotifier.ts @@ -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) diff --git a/scripts/utils.ts b/scripts/utils.ts index f9a9e2d6..560d25ad 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -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