@samitouri / QOS-React-2 / commits / 7ae8909504

Move IE8 onscroll check

Rather than checking if document.onscroll exists in EventPluginHub (which is agnostic of the DOM) do it in ReactDOMComponent

Andrew Rasmussen committed Sep 10, 2014 at 13:33 UTC 7ae8909504667629a5f5ae1459664d57893a03ed
2 files changed +11 -11
src/browser/ui/ReactDOMComponent.js
+11
@@ -31,9 +31,11 @@ var ReactPerf = require('ReactPerf');
31
32 var escapeTextForBrowser = require('escapeTextForBrowser');
33 var invariant = require('invariant');
34 +var isEventSupported = require('isEventSupported');
35 var keyOf = require('keyOf');
36 var merge = require('merge');
37 var mixInto = require('mixInto');
38 +var monitorCodeUse = require('monitorCodeUse');
39
40 var deleteListener = ReactBrowserEventEmitter.deleteListener;
41 var listenTo = ReactBrowserEventEmitter.listenTo;
@@ -66,6 +68,15 @@ function assertValidProps(props) {
68 }
69
70 function putListener(id, registrationName, listener, transaction) {
71 + if (__DEV__) {
72 + // IE8 has no API for event capturing and the `onScroll` event doesn't
73 + // bubble.
74 + if (registrationName === 'onScroll' &&
75 + !isEventSupported('scroll', true)) {
76 + monitorCodeUse('react_no_scroll_event');
77 + console.warn('This browser doesn\'t support the `onScroll` event');
78 + }
79 + }
80 var container = ReactMount.findReactContainerForID(id);
81 if (container) {
82 var doc = container.nodeType === ELEMENT_NODE_TYPE ?
src/event/EventPluginHub.js
-11
@@ -24,8 +24,6 @@ var EventPluginUtils = require('EventPluginUtils');
24 var accumulateInto = require('accumulateInto');
25 var forEachAccumulated = require('forEachAccumulated');
26 var invariant = require('invariant');
27 -var isEventSupported = require('isEventSupported');
28 -var monitorCodeUse = require('monitorCodeUse');
27
28 /**
29 * Internal store for event listeners
@@ -159,15 +157,6 @@ var EventPluginHub = {
157 registrationName, typeof listener
158 );
159
162 - if (__DEV__) {
163 - // IE8 has no API for event capturing and the `onScroll` event doesn't
164 - // bubble.
165 - if (registrationName === 'onScroll' &&
166 - !isEventSupported('scroll', true)) {
167 - monitorCodeUse('react_no_scroll_event');
168 - console.warn('This browser doesn\'t support the `onScroll` event');
169 - }
170 - }
160 var bankForRegistrationName =
161 listenerBank[registrationName] || (listenerBank[registrationName] = {});
162 bankForRegistrationName[id] = listener;