From 5d484ee8731538e0526ddadca1a8d758340237c7 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sat, 27 Feb 2021 13:16:59 +0900 Subject: [PATCH] refactoring --- src/client/os.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/client/os.ts b/src/client/os.ts index fe4054e27..a971eebd4 100644 --- a/src/client/os.ts +++ b/src/client/os.ts @@ -323,16 +323,13 @@ export async function openEmojiPicker(src?: HTMLElement, opts, initialTextarea: const observer = new MutationObserver(records => { for (const record of records) { - for (const node of Array.from(record.addedNodes)) { - if (node instanceof HTMLElement) { - const textareas = node.querySelectorAll('textarea, input'); - for (const textarea of Array.from(textareas)) { - if (textarea.dataset.preventEmojiInsert != null) return; - if (document.activeElement === textarea) activeTextarea = textarea; - textarea.addEventListener('focus', () => { - activeTextarea = textarea; - }); - } + for (const node of Array.from(record.addedNodes).filter(node => node instanceof HTMLElement) as HTMLElement[]) { + const textareas = node.querySelectorAll('textarea, input') as NodeListOf>; + for (const textarea of Array.from(textareas).filter(textarea => textarea.dataset.preventEmojiInsert == null)) { + if (document.activeElement === textarea) activeTextarea = textarea; + textarea.addEventListener('focus', () => { + activeTextarea = textarea; + }); } } }