UNPKG

895 BJavaScriptView Raw
1/**
2 * Copyright (c) 2013-present, Facebook, Inc.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 *
8 */
9
10'use strict';
11
12/**
13 * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
14 */
15
16var supportedInputTypes = {
17 color: true,
18 date: true,
19 datetime: true,
20 'datetime-local': true,
21 email: true,
22 month: true,
23 number: true,
24 password: true,
25 range: true,
26 search: true,
27 tel: true,
28 text: true,
29 time: true,
30 url: true,
31 week: true
32};
33
34function isTextInputElement(elem) {
35 var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
36
37 if (nodeName === 'input') {
38 return !!supportedInputTypes[elem.type];
39 }
40
41 if (nodeName === 'textarea') {
42 return true;
43 }
44
45 return false;
46}
47
48module.exports = isTextInputElement;
\No newline at end of file