Prefer window.getSelection for IE

IE9+ supports `window.getSelection()` but `SelectEventPlugin` gives precedence to `document.selection` instead. `document.selection` is still available in later versions of IE, but the modern Selection object is preferable. Swap the two.
This commit is contained in:
Isaac Salier-Hellendag authored and Paul O’Shannessy committed 2014-09-22 16:56:22 -07:00
1 parent 176d47319a
commit e7299f6039
1 file changed
+8 -8
@@ -69,6 +69,14 @@ function getSelection(node) {
start: node.selectionStart,
end: node.selectionEnd
};
} else if (window.getSelection) {
var selection = window.getSelection();
return {
anchorNode: selection.anchorNode,
anchorOffset: selection.anchorOffset,
focusNode: selection.focusNode,
focusOffset: selection.focusOffset
};
} else if (document.selection) {
var range = document.selection.createRange();
return {
@@ -77,14 +85,6 @@ function getSelection(node) {
top: range.boundingTop,
left: range.boundingLeft
};
} else {
var selection = window.getSelection();
return {
anchorNode: selection.anchorNode,
anchorOffset: selection.anchorOffset,
focusNode: selection.focusNode,
focusOffset: selection.focusOffset
};
}
}