MCPcopy Index your code
hub / github.com/krasimir/react-in-patterns / getSelection

Function getSelection

code/composition/public/app.js:6765–6780  ·  view source on GitHub ↗

* Get an object which is a unique representation of the current selection. * * The return value will not be consistent across nodes or browsers, but * two identical selections on the same node will return identical objects. * * @param {DOMElement} node * @return {object}

(node)

Source from the content-addressed store, hash-verified

6763 * @return {object}
6764 */
6765function getSelection(node) {
6766 if ('selectionStart' in node && hasSelectionCapabilities(node)) {
6767 return {
6768 start: node.selectionStart,
6769 end: node.selectionEnd
6770 };
6771 } else if (window.getSelection) {
6772 var selection = window.getSelection();
6773 return {
6774 anchorNode: selection.anchorNode,
6775 anchorOffset: selection.anchorOffset,
6776 focusNode: selection.focusNode,
6777 focusOffset: selection.focusOffset
6778 };
6779 }
6780}
6781
6782/**
6783 * Poll selection to see whether it's changed.

Callers 1

constructSelectEventFunction · 0.70

Calls 1

hasSelectionCapabilitiesFunction · 0.70

Tested by

no test coverage detected