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.
Isaac Salier-Hellendag committed
Sep 22, 2014 at 15:01 UTC
e7299f60393f95b346285181c6ca8e09d8edea1b
1 file changed
+8
-8
src/browser/eventPlugins/SelectEventPlugin.js
+8
-8
@@ -69,6 +69,14 @@ function getSelection(node) {
69
start: node.selectionStart,
70
end: node.selectionEnd
71
};
72
+ } else if (window.getSelection) {
73
+ var selection = window.getSelection();
74
+ return {
75
+ anchorNode: selection.anchorNode,
76
+ anchorOffset: selection.anchorOffset,
77
+ focusNode: selection.focusNode,
78
+ focusOffset: selection.focusOffset
79
+ };
80
} else if (document.selection) {
81
var range = document.selection.createRange();
82
return {
@@ -77,14 +85,6 @@ function getSelection(node) {
85
top: range.boundingTop,
86
left: range.boundingLeft
87
};
80
- } else {
81
- var selection = window.getSelection();
82
- return {
83
- anchorNode: selection.anchorNode,
84
- anchorOffset: selection.anchorOffset,
85
- focusNode: selection.focusNode,
86
- focusOffset: selection.focusOffset
87
- };
88
}
89
}
90