From e7299f60393f95b346285181c6ca8e09d8edea1b Mon Sep 17 00:00:00 2001 From: Isaac Salier-Hellendag Date: Mon, 22 Sep 2014 15:01:59 -0700 Subject: [PATCH] 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. --- src/browser/eventPlugins/SelectEventPlugin.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/browser/eventPlugins/SelectEventPlugin.js b/src/browser/eventPlugins/SelectEventPlugin.js index 542dbe5b39..3cfcc020ba 100644 --- a/src/browser/eventPlugins/SelectEventPlugin.js +++ b/src/browser/eventPlugins/SelectEventPlugin.js @@ -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 - }; } }