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

Function setSelection

code/third-party/public/app.js:5818–5832  ·  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

5816 * -@offsets Object of same form that is returned from get*
5817 */
5818function setSelection(input, offsets) {
5819 var start = offsets.start,
5820 end = offsets.end;
5821
5822 if (end === undefined) {
5823 end = start;
5824 }
5825
5826 if ('selectionStart' in input) {
5827 input.selectionStart = start;
5828 input.selectionEnd = Math.min(end, input.value.length);
5829 } else {
5830 setOffsets(input, offsets);
5831 }
5832}
5833
5834var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11;
5835

Callers 1

restoreSelectionFunction · 0.70

Calls 1

setOffsetsFunction · 0.70

Tested by

no test coverage detected