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

Function setSelection

code/redux/public/app.js:6836–6850  ·  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

6834 * -@offsets Object of same form that is returned from get*
6835 */
6836function setSelection(input, offsets) {
6837 var start = offsets.start,
6838 end = offsets.end;
6839
6840 if (end === undefined) {
6841 end = start;
6842 }
6843
6844 if ('selectionStart' in input) {
6845 input.selectionStart = start;
6846 input.selectionEnd = Math.min(end, input.value.length);
6847 } else {
6848 setOffsets(input, offsets);
6849 }
6850}
6851
6852var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11;
6853

Callers 1

restoreSelectionFunction · 0.70

Calls 1

setOffsetsFunction · 0.70

Tested by

no test coverage detected