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

Function getSelection

code/styling/public/app.js:6627–6642  ·  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

6625 * @return {object}
6626 */
6627function getSelection(node) {
6628 if ('selectionStart' in node && hasSelectionCapabilities(node)) {
6629 return {
6630 start: node.selectionStart,
6631 end: node.selectionEnd
6632 };
6633 } else if (window.getSelection) {
6634 var selection = window.getSelection();
6635 return {
6636 anchorNode: selection.anchorNode,
6637 anchorOffset: selection.anchorOffset,
6638 focusNode: selection.focusNode,
6639 focusOffset: selection.focusOffset
6640 };
6641 }
6642}
6643
6644/**
6645 * Poll selection to see whether it's changed.

Callers 1

constructSelectEventFunction · 0.70

Calls 1

hasSelectionCapabilitiesFunction · 0.70

Tested by

no test coverage detected