UNPKG

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