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

Function getSelection

code/communication/public/app.js:6662–6677  ·  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

6660 * @return {object}
6661 */
6662function getSelection(node) {
6663 if ('selectionStart' in node && hasSelectionCapabilities(node)) {
6664 return {
6665 start: node.selectionStart,
6666 end: node.selectionEnd
6667 };
6668 } else if (window.getSelection) {
6669 var selection = window.getSelection();
6670 return {
6671 anchorNode: selection.anchorNode,
6672 anchorOffset: selection.anchorOffset,
6673 focusNode: selection.focusNode,
6674 focusOffset: selection.focusOffset
6675 };
6676 }
6677}
6678
6679/**
6680 * Poll selection to see whether it's changed.

Callers 1

constructSelectEventFunction · 0.70

Calls 1

hasSelectionCapabilitiesFunction · 0.70

Tested by

no test coverage detected