Use warning module

This commit is contained in:
Charles Marsh 2014-08-23 09:25:32 +08:00
parent 979a93a70a
commit eb36b57079
2 changed files with 10 additions and 11 deletions

View File

@ -275,8 +275,8 @@ describe('ReactBrowserEventEmitter', function() {
expect(idCallOrder[0]).toBe(getID(CHILD));
expect(console.warn.calls.length).toEqual(1);
expect(console.warn.calls[0].args[0]).toBe(
'Returning `false` from an event handler is deprecated and will ' +
'be ignored in a future release. Instead, manually call ' +
'Warning: Returning `false` from an event handler is deprecated and ' +
'will be ignored in a future release. Instead, manually call ' +
'e.stopPropagation() or e.preventDefault(), as appropriate.'
);
});

View File

@ -35,6 +35,7 @@ var getEventCharCode = require('getEventCharCode');
var invariant = require('invariant');
var keyOf = require('keyOf');
var warning = require('warning');
var topLevelTypes = EventConstants.topLevelTypes;
@ -309,15 +310,13 @@ var SimpleEventPlugin = {
*/
executeDispatch: function(event, listener, domID) {
var returnValue = EventPluginUtils.executeDispatch(event, listener, domID);
if (__DEV__) {
if (typeof returnValue === 'boolean') {
console.warn(
'Returning `false` from an event handler is deprecated and will ' +
'be ignored in a future release. Instead, manually call ' +
'e.stopPropagation() or e.preventDefault(), as appropriate.'
);
}
}
warning(
typeof returnValue !== 'boolean',
'Returning `false` from an event handler is deprecated and will be ' +
'ignored in a future release. Instead, manually call ' +
'e.stopPropagation() or e.preventDefault(), as appropriate.'
);
if (returnValue === false) {
event.stopPropagation();