* 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)
| 6660 | * @return {object} |
| 6661 | */ |
| 6662 | function 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. |
no test coverage detected