MCPcopy Create free account
hub / github.com/krasimir/react-in-patterns / getSelection$1

Function getSelection$1

code/styling/public/app.js:6562–6577  ·  view source on GitHub ↗

* @getSelection: Gets the selection bounds of a focused textarea, input or * contentEditable node. * -@input: Look up selection bounds of this input * -@return {start: selectionStart, end: selectionEnd}

(input)

Source from the content-addressed store, hash-verified

6560 * -@return {start: selectionStart, end: selectionEnd}
6561 */
6562function getSelection$1(input) {
6563 var selection = void 0;
6564
6565 if ('selectionStart' in input) {
6566 // Modern browser with input or textarea.
6567 selection = {
6568 start: input.selectionStart,
6569 end: input.selectionEnd
6570 };
6571 } else {
6572 // Content editable or old IE textarea.
6573 selection = getOffsets(input);
6574 }
6575
6576 return selection || { start: 0, end: 0 };
6577}
6578
6579/**
6580 * @setSelection: Sets the selection bounds of a textarea or input and focuses

Callers 1

getSelectionInformationFunction · 0.70

Calls 1

getOffsetsFunction · 0.70

Tested by

no test coverage detected