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

Function getSelection

code/third-party/public/app.js:5860–5875  ·  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

5858 * @return {object}
5859 */
5860function getSelection(node) {
5861 if ('selectionStart' in node && hasSelectionCapabilities(node)) {
5862 return {
5863 start: node.selectionStart,
5864 end: node.selectionEnd
5865 };
5866 } else if (window.getSelection) {
5867 var selection = window.getSelection();
5868 return {
5869 anchorNode: selection.anchorNode,
5870 anchorOffset: selection.anchorOffset,
5871 focusNode: selection.focusNode,
5872 focusOffset: selection.focusOffset
5873 };
5874 }
5875}
5876
5877/**
5878 * Poll selection to see whether it's changed.

Callers 1

constructSelectEventFunction · 0.70

Calls 1

hasSelectionCapabilitiesFunction · 0.70

Tested by

no test coverage detected