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

Function setSelection

code/styling/public/app.js:6585–6599  ·  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

6583 * -@offsets Object of same form that is returned from get*
6584 */
6585function setSelection(input, offsets) {
6586 var start = offsets.start,
6587 end = offsets.end;
6588
6589 if (end === undefined) {
6590 end = start;
6591 }
6592
6593 if ('selectionStart' in input) {
6594 input.selectionStart = start;
6595 input.selectionEnd = Math.min(end, input.value.length);
6596 } else {
6597 setOffsets(input, offsets);
6598 }
6599}
6600
6601var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11;
6602

Callers 1

restoreSelectionFunction · 0.70

Calls 1

setOffsetsFunction · 0.70

Tested by

no test coverage detected