| 431 | }; |
| 432 | |
| 433 | const selectFoundInputElement = function () { |
| 434 | // Since the last focused element might not be the one currently pointed to by find (e.g. the |
| 435 | // current one might be disabled and therefore unable to receive focus), we use the approximate |
| 436 | // heuristic of checking that the last anchor node is an ancestor of our element. |
| 437 | const findModeAnchorNode = document.getSelection().anchorNode; |
| 438 | if ( |
| 439 | FindMode.query.hasResults && document.activeElement && |
| 440 | DomUtils.isSelectable(document.activeElement) && |
| 441 | DomUtils.isDOMDescendant(findModeAnchorNode, document.activeElement) |
| 442 | ) { |
| 443 | return DomUtils.simulateSelect(document.activeElement); |
| 444 | } |
| 445 | }; |
| 446 | |
| 447 | // Retrieve the starting indices of all matches of the queried pattern within the given text. |
| 448 | const getRegexMatchIndices = (text, regex) => { |