MCPcopy
hub / github.com/autoNumeric/autoNumeric / setElementSelection

Method setElementSelection

src/AutoNumericHelper.js:734–749  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

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

Callers 12

_defaultSelectAllMethod · 0.80
selectNumberMethod · 0.80
selectIntegerMethod · 0.80
selectDecimalMethod · 0.80
_onFocusInMethod · 0.80
_enterFormulaModeMethod · 0.80
_onKeypressMethod · 0.80
_onKeyupMethod · 0.80
_onPasteMethod · 0.80
_setSelectionMethod · 0.80

Calls 3

isInputElementMethod · 0.95
isNullMethod · 0.80

Tested by

no test coverage detected