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

Function getSelection

code/redux/public/app.js:6878–6893  ·  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

6876 * @return {object}
6877 */
6878function getSelection(node) {
6879 if ('selectionStart' in node && hasSelectionCapabilities(node)) {
6880 return {
6881 start: node.selectionStart,
6882 end: node.selectionEnd
6883 };
6884 } else if (window.getSelection) {
6885 var selection = window.getSelection();
6886 return {
6887 anchorNode: selection.anchorNode,
6888 anchorOffset: selection.anchorOffset,
6889 focusNode: selection.focusNode,
6890 focusOffset: selection.focusOffset
6891 };
6892 }
6893}
6894
6895/**
6896 * Poll selection to see whether it's changed.

Callers 1

constructSelectEventFunction · 0.70

Calls 1

hasSelectionCapabilitiesFunction · 0.70

Tested by

no test coverage detected