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

Function getSelection$1

code/communication/public/app.js:6597–6612  ·  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

6595 * -@return {start: selectionStart, end: selectionEnd}
6596 */
6597function getSelection$1(input) {
6598 var selection = void 0;
6599
6600 if ('selectionStart' in input) {
6601 // Modern browser with input or textarea.
6602 selection = {
6603 start: input.selectionStart,
6604 end: input.selectionEnd
6605 };
6606 } else {
6607 // Content editable or old IE textarea.
6608 selection = getOffsets(input);
6609 }
6610
6611 return selection || { start: 0, end: 0 };
6612}
6613
6614/**
6615 * @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