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

Function setSelection

code/higher-order-components/public/app.js:6579–6593  ·  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

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

Callers 1

restoreSelectionFunction · 0.70

Calls 1

setOffsetsFunction · 0.70

Tested by

no test coverage detected