* Find the path of Editor node.
(editor: Editor, node: Node)
| 287 | */ |
| 288 | |
| 289 | findPath(editor: Editor, node: Node): Path { |
| 290 | const path: Path = [] |
| 291 | let child = node |
| 292 | |
| 293 | while (true) { |
| 294 | const parent = NODE_TO_PARENT.get(child) |
| 295 | |
| 296 | if (parent == null) { |
| 297 | if (Editor.isEditor(child)) { |
| 298 | return path |
| 299 | } else { |
| 300 | break |
| 301 | } |
| 302 | } |
| 303 | |
| 304 | const i = NODE_TO_INDEX.get(child) |
| 305 | |
| 306 | if (i == null) { |
| 307 | break |
| 308 | } |
| 309 | |
| 310 | path.unshift(i) |
| 311 | child = parent |
| 312 | } |
| 313 | |
| 314 | throw new Error(`Unable to find the path for Editor node: ${Scrubber.stringify(node)}`) |
| 315 | }, |
| 316 | |
| 317 | /** |
| 318 | * Find the DOM node that implements DocumentOrShadowRoot for the editor. |
nothing calls this directly
no test coverage detected
searching dependent graphs…