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

Function setSelection

code/composition/public/app.js:6723–6737  ·  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

6721 * -@offsets Object of same form that is returned from get*
6722 */
6723function setSelection(input, offsets) {
6724 var start = offsets.start,
6725 end = offsets.end;
6726
6727 if (end === undefined) {
6728 end = start;
6729 }
6730
6731 if ('selectionStart' in input) {
6732 input.selectionStart = start;
6733 input.selectionEnd = Math.min(end, input.value.length);
6734 } else {
6735 setOffsets(input, offsets);
6736 }
6737}
6738
6739var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11;
6740

Callers 1

restoreSelectionFunction · 0.70

Calls 1

setOffsetsFunction · 0.70

Tested by

no test coverage detected