UNPKG

@gechiui/dom

Version:
34 lines (28 loc) 1.15 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = isTextField; var _isHtmlInputElement = _interopRequireDefault(require("./is-html-input-element")); /** * Internal dependencies */ /* eslint-disable jsdoc/valid-types */ /** * Check whether the given element is a text field, where text field is defined * by the ability to select within the input, or that it is contenteditable. * * See: https://html.spec.whatwg.org/#textFieldSelection * * @param {Node} node The HTML element. * @return {node is HTMLElement} True if the element is an text field, false if not. */ function isTextField(node) { /* eslint-enable jsdoc/valid-types */ const nonTextInputs = ['button', 'checkbox', 'hidden', 'file', 'radio', 'image', 'range', 'reset', 'submit', 'number']; return (0, _isHtmlInputElement.default)(node) && node.type && !nonTextInputs.includes(node.type) || node.nodeName === 'TEXTAREA' || /** @type {HTMLElement} */ node.contentEditable === 'true'; } //# sourceMappingURL=is-text-field.js.map