mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
adding warning about the lack of support for onScroll on IE8
Adding `console.warn` about the lack of support for `onScroll` event on IE8 Related to this issue on github https://github.com/facebook/react/issues/631
This commit is contained in:
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var isEventSupported = require('isEventSupported');
|
||||||
|
|
||||||
var listenerBank = {};
|
var listenerBank = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,6 +42,14 @@ var CallbackRegistry = {
|
|||||||
* @param {?function} listener The callback to store.
|
* @param {?function} listener The callback to store.
|
||||||
*/
|
*/
|
||||||
putListener: function(id, registrationName, listener) {
|
putListener: function(id, registrationName, listener) {
|
||||||
|
if (__DEV__) {
|
||||||
|
// IE8 has no API for event capturing and the `onScroll` event doesn't
|
||||||
|
// bubble.
|
||||||
|
if (registrationName === 'onScroll' &&
|
||||||
|
!isEventSupported('scroll', true)) {
|
||||||
|
console.warn('This browser doesn\'t support the `onScroll` event');
|
||||||
|
}
|
||||||
|
}
|
||||||
var bankForRegistrationName =
|
var bankForRegistrationName =
|
||||||
listenerBank[registrationName] || (listenerBank[registrationName] = {});
|
listenerBank[registrationName] || (listenerBank[registrationName] = {});
|
||||||
bankForRegistrationName[id] = listener;
|
bankForRegistrationName[id] = listener;
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* Copyright 2013 Facebook, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* @emails react-core
|
||||||
|
*/
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
require('mock-modules')
|
||||||
|
.dontMock('CallbackRegistry')
|
||||||
|
.mock('isEventSupported');
|
||||||
|
|
||||||
|
describe('CallbackRegistry', function() {
|
||||||
|
var CallbackRegistry;
|
||||||
|
var isEventSupported;
|
||||||
|
|
||||||
|
beforeEach(function() {
|
||||||
|
require('mock-modules').dumpCache();
|
||||||
|
CallbackRegistry = require('CallbackRegistry');
|
||||||
|
isEventSupported = require('isEventSupported');
|
||||||
|
isEventSupported.mockReturnValue(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should warn about the `onScroll` issue on IE8', function() {
|
||||||
|
spyOn(console, 'warn');
|
||||||
|
CallbackRegistry.putListener(1, 'onScroll', function(){});
|
||||||
|
expect(console.warn.callCount).toBe(1);
|
||||||
|
expect(console.warn.mostRecentCall.args[0]).toBe(
|
||||||
|
'This browser doesn\'t support the `onScroll` event'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user