MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / setSelection

Function setSelection

code/dependency-injection/public/app.js:6678–6692  ·  view source on GitHub ↗

* @setSelection: Sets the selection bounds of a textarea or input and focuses * the input. * -@input Set selection bounds of this input or textarea * -@offsets Object of same form that is returned from get*

(input, offsets)

Source from the content-addressed store, hash-verified

6676 * -@offsets Object of same form that is returned from get*
6677 */
6678function setSelection(input, offsets) {
6679 var start = offsets.start,
6680 end = offsets.end;
6681
6682 if (end === undefined) {
6683 end = start;
6684 }
6685
6686 if ('selectionStart' in input) {
6687 input.selectionStart = start;
6688 input.selectionEnd = Math.min(end, input.value.length);
6689 } else {
6690 setOffsets(input, offsets);
6691 }
6692}
6693
6694var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11;
6695

Callers 1

restoreSelectionFunction · 0.70

Calls 1

setOffsetsFunction · 0.70

Tested by

no test coverage detected