* Check if a DOM node is within the editor.
(editor: Editor, target: DOMNode)
| 373 | * Check if a DOM node is within the editor. |
| 374 | */ |
| 375 | hasDOMNode(editor: Editor, target: DOMNode): boolean { |
| 376 | const editorEl = Editable.toDOMNode(editor, editor) |
| 377 | let targetEl |
| 378 | |
| 379 | // COMPAT: In Firefox, reading `target.nodeType` will throw an error if |
| 380 | // target is originating from an internal "restricted" element (e.g. a |
| 381 | // stepper arrow on a number input). (2018/05/04) |
| 382 | // https://github.com/ianstormtaylor/slate/issues/1819 |
| 383 | try { |
| 384 | targetEl = (isDOMElement(target) ? target : target.parentElement) as HTMLElement |
| 385 | } catch (err: any) { |
| 386 | if (!err.message.includes('Permission denied to access property "nodeType"')) { |
| 387 | throw err |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | if (!targetEl) { |
| 392 | return false |
| 393 | } |
| 394 | |
| 395 | return targetEl.closest(`[${DATA_EDITABLE_NODE}="editor"]`) === editorEl |
| 396 | }, |
| 397 | |
| 398 | /** |
| 399 | * Find the native DOM element from a Editor node. |
nothing calls this directly
no test coverage detected
searching dependent graphs…