* Cross browser routine for setting selected range/cursor position * * @param {HTMLInputElement|EventTarget} element * @param {number} start * @param {number|null} [end=null]
(element, start, end = null)
| 732 | * @param {number|null} [end=null] |
| 733 | */ |
| 734 | static setElementSelection(element, start, end = null) { |
| 735 | if (this.isUndefinedOrNullOrEmpty(end)) { |
| 736 | end = start; |
| 737 | } |
| 738 | |
| 739 | if (this.isInputElement(element)) { |
| 740 | element.setSelectionRange(start, end); |
| 741 | } else if (!AutoNumericHelper.isNull(element.firstChild)) { |
| 742 | const range = document.createRange(); |
| 743 | range.setStart(element.firstChild, start); |
| 744 | range.setEnd(element.firstChild, end); |
| 745 | const selection = window.getSelection(); |
| 746 | selection.removeAllRanges(); |
| 747 | selection.addRange(range); |
| 748 | } |
| 749 | } |
| 750 | |
| 751 | /** |
| 752 | * Function that throw error messages |
no test coverage detected