From d01db82c0dca352de2d7644c383d388fc3ec0366 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Thu, 2 May 2019 14:08:51 +0900 Subject: Types src/content --- src/content/focuses.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/content/focuses.ts') diff --git a/src/content/focuses.ts b/src/content/focuses.ts index a6f6cc8..8f53881 100644 --- a/src/content/focuses.ts +++ b/src/content/focuses.ts @@ -1,11 +1,13 @@ -import * as doms from 'shared/utils/dom'; +import * as doms from '../shared/utils/dom'; -const focusInput = () => { +const focusInput = (): void => { let inputTypes = ['email', 'number', 'search', 'tel', 'text', 'url']; let inputSelector = inputTypes.map(type => `input[type=${type}]`).join(','); let targets = window.document.querySelectorAll(inputSelector + ',textarea'); let target = Array.from(targets).find(doms.isVisible); - if (target) { + if (target instanceof HTMLInputElement) { + target.focus(); + } else if (target instanceof HTMLTextAreaElement) { target.focus(); } }; -- cgit v1.2.3