mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
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
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user