MCPcopy Create free account
hub / github.com/microsoft/SandDance / getSelection

Function getSelection

docs/external/js/react-dom.development.js:7151–7169  ·  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

7149 */
7150
7151 function getSelection(input) {
7152 var selection;
7153
7154 if ('selectionStart' in input) {
7155 // Modern browser with input or textarea.
7156 selection = {
7157 start: input.selectionStart,
7158 end: input.selectionEnd
7159 };
7160 } else {
7161 // Content editable or old IE textarea.
7162 selection = getOffsets(input);
7163 }
7164
7165 return selection || {
7166 start: 0,
7167 end: 0
7168 };
7169 }
7170 /**
7171 * @setSelection: Sets the selection bounds of a textarea or input and focuses
7172 * the input.

Callers 1

getSelectionInformationFunction · 0.85

Calls 1

getOffsetsFunction · 0.70

Tested by

no test coverage detected