* 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)
| 6763 | * @return {object} |
| 6764 | */ |
| 6765 | function getSelection(node) { |
| 6766 | if ('selectionStart' in node && hasSelectionCapabilities(node)) { |
| 6767 | return { |
| 6768 | start: node.selectionStart, |
| 6769 | end: node.selectionEnd |
| 6770 | }; |
| 6771 | } else if (window.getSelection) { |
| 6772 | var selection = window.getSelection(); |
| 6773 | return { |
| 6774 | anchorNode: selection.anchorNode, |
| 6775 | anchorOffset: selection.anchorOffset, |
| 6776 | focusNode: selection.focusNode, |
| 6777 | focusOffset: selection.focusOffset |
| 6778 | }; |
| 6779 | } |
| 6780 | } |
| 6781 | |
| 6782 | /** |
| 6783 | * Poll selection to see whether it's changed. |
no test coverage detected