* 检查元素是否为输入元素
(element: HTMLElement)
| 741 | * 检查元素是否为输入元素 |
| 742 | */ |
| 743 | function isInputElement(element: HTMLElement): boolean { |
| 744 | if (!element) return false; |
| 745 | |
| 746 | const tagName = element.tagName.toLowerCase(); |
| 747 | const isInput = tagName === 'input'; |
| 748 | const isTextarea = tagName === 'textarea'; |
| 749 | const isContentEditable = element.contentEditable === 'true'; |
| 750 | |
| 751 | // 对于input元素,还需要检查type属性 |
| 752 | if (isInput) { |
| 753 | const inputType = (element as HTMLInputElement).type.toLowerCase(); |
| 754 | const textInputTypes = ['text', 'search', 'url', 'email', 'password']; |
| 755 | return textInputTypes.includes(inputType); |
| 756 | } |
| 757 | |
| 758 | return isTextarea || isContentEditable; |
| 759 | } |
| 760 | |
| 761 | /** |
| 762 | * 获取输入框中的文本 |
no outgoing calls
no test coverage detected