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

Function getSelection

code/dependency-injection/public/app.js:6720–6735  ·  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

6718 * @return {object}
6719 */
6720function getSelection(node) {
6721 if ('selectionStart' in node && hasSelectionCapabilities(node)) {
6722 return {
6723 start: node.selectionStart,
6724 end: node.selectionEnd
6725 };
6726 } else if (window.getSelection) {
6727 var selection = window.getSelection();
6728 return {
6729 anchorNode: selection.anchorNode,
6730 anchorOffset: selection.anchorOffset,
6731 focusNode: selection.focusNode,
6732 focusOffset: selection.focusOffset
6733 };
6734 }
6735}
6736
6737/**
6738 * Poll selection to see whether it's changed.

Callers 1

constructSelectEventFunction · 0.70

Calls 1

hasSelectionCapabilitiesFunction · 0.70

Tested by

no test coverage detected