From fc748fefb8a5c1a93b652bcd6b2d706f3470a8d1 Mon Sep 17 00:00:00 2001 From: Misode Date: Fri, 5 Feb 2021 23:59:58 +0100 Subject: [PATCH] Not-so-magic performance improvement --- src/app/views/View.ts | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/app/views/View.ts b/src/app/views/View.ts index 690110fc..4833cb42 100644 --- a/src/app/views/View.ts +++ b/src/app/views/View.ts @@ -40,13 +40,10 @@ export class View implements Mounter{ } mounted(el: Element, clear = true): void { - for (const id in this.registry) { - const element = el.querySelector(`[data-id="${id}"]`) - if (element !== null) { - this.registry[id](element) - delete this.registry[id] - } - } + el.querySelectorAll('[data-id]').forEach(el => { + const id = el.getAttribute('data-id')! + this.registry[id]?.(el) + }) if (clear) { this.registry = {} }