is text input element
一、作用
二、判定是否为文本输入元素
function isTextInputElement(elem: ?HTMLElement): boolean {
const nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
if (nodeName === 'input') {
return !!supportedInputTypes[(elem as any as HTMLInputElement).type];
}
if (nodeName === 'textarea') {
return true;
}
return false;
}
三、常量
1. 支持的输入类型
/**
* @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
*/
const supportedInputTypes: { [key: string]: true | undefined } = {
color: true,
date: true,
datetime: true,
'datetime-local': true,
email: true,
month: true,
number: true,
password: true,
range: true,
search: true,
tel: true,
text: true,
time: true,
url: true,
week: true,
};