* 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)
| 5986 | * @return {object} |
| 5987 | */ |
| 5988 | function getSelection(node) { |
| 5989 | if ('selectionStart' in node && hasSelectionCapabilities(node)) { |
| 5990 | return { |
| 5991 | start: node.selectionStart, |
| 5992 | end: node.selectionEnd |
| 5993 | }; |
| 5994 | } else if (window.getSelection) { |
| 5995 | var selection = window.getSelection(); |
| 5996 | return { |
| 5997 | anchorNode: selection.anchorNode, |
| 5998 | anchorOffset: selection.anchorOffset, |
| 5999 | focusNode: selection.focusNode, |
| 6000 | focusOffset: selection.focusOffset |
| 6001 | }; |
| 6002 | } |
| 6003 | } |
| 6004 | |
| 6005 | /** |
| 6006 | * Poll selection to see whether it's changed. |
no test coverage detected