Function
isFormEvent
(e: KeyboardEvent | MouseEvent)
Source from the content-addressed store, hash-verified
| 2 | * 检查事件是否由表单元素触发 |
| 3 | */ |
| 4 | export const isFormEvent = (e: KeyboardEvent | MouseEvent) => { |
| 5 | const t = e.target as HTMLFormElement |
| 6 | if (!t) { |
| 7 | return false |
| 8 | } |
| 9 | |
| 10 | if (t.form || /^(INPUT|SELECT|TEXTAREA)$/.test(t.tagName)) { |
| 11 | return true |
| 12 | } |
| 13 | if (t instanceof HTMLElement && /write/.test(window.getComputedStyle(t).getPropertyValue('-webkit-user-modify'))) { |
| 14 | return true |
| 15 | } |
| 16 | return false |
| 17 | } |
Tested by
no test coverage detected