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

Function setSelection

code/communication/public/app.js:6620–6634  ·  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

6618 * -@offsets Object of same form that is returned from get*
6619 */
6620function setSelection(input, offsets) {
6621 var start = offsets.start,
6622 end = offsets.end;
6623
6624 if (end === undefined) {
6625 end = start;
6626 }
6627
6628 if ('selectionStart' in input) {
6629 input.selectionStart = start;
6630 input.selectionEnd = Math.min(end, input.value.length);
6631 } else {
6632 setOffsets(input, offsets);
6633 }
6634}
6635
6636var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11;
6637

Callers 1

restoreSelectionFunction · 0.70

Calls 1

setOffsetsFunction · 0.70

Tested by

no test coverage detected