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

Function getSelection$1

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

5921 * -@return {start: selectionStart, end: selectionEnd}
5922 */
5923function getSelection$1(input) {
5924 var selection = void 0;
5925
5926 if ('selectionStart' in input) {
5927 // Modern browser with input or textarea.
5928 selection = {
5929 start: input.selectionStart,
5930 end: input.selectionEnd
5931 };
5932 } else {
5933 // Content editable or old IE textarea.
5934 selection = getOffsets(input);
5935 }
5936
5937 return selection || { start: 0, end: 0 };
5938}
5939
5940/**
5941 * @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