1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.clear = clear;
|
7 |
|
8 | var _type = require("./type");
|
9 |
|
10 | function clear(element) {
|
11 | if (element.tagName !== 'INPUT' && element.tagName !== 'TEXTAREA') {
|
12 |
|
13 | throw new Error('clear currently only supports input and textarea elements.');
|
14 | }
|
15 |
|
16 | if (element.disabled) return;
|
17 |
|
18 |
|
19 | const elementType = element.type;
|
20 |
|
21 | if (element.tagName === 'INPUT') {
|
22 |
|
23 | element.type = 'text';
|
24 | }
|
25 |
|
26 | (0, _type.type)(element, '{selectall}{del}', {
|
27 | delay: 0,
|
28 | initialSelectionStart: element.selectionStart,
|
29 | initialSelectionEnd: element.selectionEnd
|
30 | });
|
31 |
|
32 | if (element.tagName === 'INPUT') {
|
33 | element.type = elementType;
|
34 | }
|
35 | } |
\ | No newline at end of file |