Types src/content

This commit is contained in:
Shin'ya Ueoka 2019-05-02 14:08:51 +09:00
parent 992b3ac65d
commit d01db82c0d
62 changed files with 1411 additions and 468 deletions

View file

@ -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();
}
};