* 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)
| 5858 | * @return {object} |
| 5859 | */ |
| 5860 | function 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. |
no test coverage detected