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

Function setSelection

code/new-context-api/public/app.js:5946–5960  ·  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

5944 * -@offsets Object of same form that is returned from get*
5945 */
5946function setSelection(input, offsets) {
5947 var start = offsets.start,
5948 end = offsets.end;
5949
5950 if (end === undefined) {
5951 end = start;
5952 }
5953
5954 if ('selectionStart' in input) {
5955 input.selectionStart = start;
5956 input.selectionEnd = Math.min(end, input.value.length);
5957 } else {
5958 setOffsets(input, offsets);
5959 }
5960}
5961
5962var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11;
5963

Callers 1

restoreSelectionFunction · 0.70

Calls 1

setOffsetsFunction · 0.70

Tested by

no test coverage detected