(element)
| 308 | }, |
| 309 | |
| 310 | simulateSelect(element) { |
| 311 | // If element is already active, then we don't move the selection. However, we also won't get a |
| 312 | // new focus event. So, instead we pretend (to any active modes which care, e.g. PostFindMode) |
| 313 | // that element has been clicked. |
| 314 | if ((element === document.activeElement) && DomUtils.isEditable(document.activeElement)) { |
| 315 | return handlerStack.bubbleEvent("click", { target: element }); |
| 316 | } else { |
| 317 | element.focus(); |
| 318 | if ((element.tagName.toLowerCase() !== "textarea") || (element.value.indexOf("\n") < 0)) { |
| 319 | // If the cursor is at the start of the (non-multiline-textarea) element's contents, send it |
| 320 | // to the end. |
| 321 | // Motivation: |
| 322 | // * the end is a more useful place to focus than the start, |
| 323 | // * this way preserves the last used position (except when it's at the beginning), so the |
| 324 | // user can 'resume where they left off'. |
| 325 | // This works well for single-line inputs, however, the UX is *bad* for multiline inputs |
| 326 | // (such as text areas), and doubly so if the end of the input happens to be out of the |
| 327 | // viewport, that's why multiline-textareas are excluded. |
| 328 | // NOTE(mrmr1993): Some elements throw an error when we try to access their selection |
| 329 | // properties, so wrap this with a try. |
| 330 | try { |
| 331 | if ((element.selectionStart === 0) && (element.selectionEnd === 0)) { |
| 332 | return element.setSelectionRange(element.value.length, element.value.length); |
| 333 | } |
| 334 | } catch { |
| 335 | // Swallow |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | }, |
| 340 | |
| 341 | simulateClick(element, modifiers) { |
| 342 | if (modifiers == null) modifiers = {}; |
nothing calls this directly
no test coverage detected