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

Function getSelection$1

code/composition/public/app.js:6700–6715  ·  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

6698 * -@return {start: selectionStart, end: selectionEnd}
6699 */
6700function getSelection$1(input) {
6701 var selection = void 0;
6702
6703 if ('selectionStart' in input) {
6704 // Modern browser with input or textarea.
6705 selection = {
6706 start: input.selectionStart,
6707 end: input.selectionEnd
6708 };
6709 } else {
6710 // Content editable or old IE textarea.
6711 selection = getOffsets(input);
6712 }
6713
6714 return selection || { start: 0, end: 0 };
6715}
6716
6717/**
6718 * @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