@samitouri / QOS-React-2 / commits / 2ff7512975

Use onSelect fallback in IE

In response to https://github.com/facebook/react/issues/2722. Use the Firefox selection change fallback for IE.

Isaac Salier-Hellendag committed Aug 4, 2015 at 17:32 UTC 2ff75129756388c96c90eb03b72b3ba3dcc5475c
1 file changed +14 -1
src/renderers/dom/client/eventPlugins/SelectEventPlugin.js
+14 -1
@@ -13,6 +13,7 @@
13
14 var EventConstants = require('EventConstants');
15 var EventPropagators = require('EventPropagators');
16 +var ExecutionEnvironment = require('ExecutionEnvironment');
17 var ReactInputSelection = require('ReactInputSelection');
18 var SyntheticEvent = require('SyntheticEvent');
19
@@ -23,6 +24,12 @@ var shallowEqual = require('shallowEqual');
24
25 var topLevelTypes = EventConstants.topLevelTypes;
26
27 +var skipSelectionChangeEvent = (
28 + ExecutionEnvironment.canUseDOM &&
29 + 'documentMode' in document &&
30 + document.documentMode <= 11
31 +);
32 +
33 var eventTypes = {
34 select: {
35 phasedRegistrationNames: {
@@ -189,12 +196,18 @@ var SelectEventPlugin = {
196 return constructSelectEvent(nativeEvent, nativeEventTarget);
197
198 // Chrome and IE fire non-standard event when selection is changed (and
192 - // sometimes when it hasn't).
199 + // sometimes when it hasn't). IE's event fires out of order with respect
200 + // to key and input events on deletion, so we discard it.
201 + //
202 // Firefox doesn't support selectionchange, so check selection status
203 // after each key entry. The selection changes after keydown and before
204 // keyup, but we check on keydown as well in the case of holding down a
205 // key, when multiple keydown events are fired but only one keyup is.
206 + // This is also our approach for IE handling, for the reason above.
207 case topLevelTypes.topSelectionChange:
208 + if (skipSelectionChangeEvent) {
209 + break;
210 + }
211 case topLevelTypes.topKeyDown:
212 case topLevelTypes.topKeyUp:
213 return constructSelectEvent(nativeEvent, nativeEventTarget);