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

Function setSelection

code/one-direction-data-flow/public/app.js:6458–6472  ·  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

6456 * -@offsets Object of same form that is returned from get*
6457 */
6458function setSelection(input, offsets) {
6459 var start = offsets.start,
6460 end = offsets.end;
6461
6462 if (end === undefined) {
6463 end = start;
6464 }
6465
6466 if ('selectionStart' in input) {
6467 input.selectionStart = start;
6468 input.selectionEnd = Math.min(end, input.value.length);
6469 } else {
6470 setOffsets(input, offsets);
6471 }
6472}
6473
6474var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11;
6475

Callers 1

restoreSelectionFunction · 0.70

Calls 1

setOffsetsFunction · 0.70

Tested by

no test coverage detected