@samitouri / QOS-React-2 / commits / 429650a750

Test for both true and false

Charles Marsh committed Aug 15, 2014 at 19:35 UTC 429650a750ed2920ad4340ae0a041f6bd7410e11
2 files changed +11 -8
src/browser/__tests__/ReactBrowserEventEmitter-test.js
+3 -3
@@ -275,9 +275,9 @@ describe('ReactBrowserEventEmitter', function() {
275 expect(idCallOrder[0]).toBe(getID(CHILD));
276 expect(console.warn.calls.length).toEqual(1);
277 expect(console.warn.calls[0].args[0]).toBe(
278 - 'Returning `false` from an event handler will be deprecated in a ' +
279 - 'future release. Instead, manually call e.stopPropagation() or ' +
280 - 'e.preventDefault(), as appropriate.'
278 + 'Returning `false` from an event handler is deprecated and will ' +
279 + 'be ignored in a future release. Instead, manually call ' +
280 + 'e.stopPropagation() or e.preventDefault(), as appropriate.'
281 );
282 });
283
src/browser/eventPlugins/SimpleEventPlugin.js
+8 -5
@@ -310,15 +310,18 @@ var SimpleEventPlugin = {
310 */
311 executeDispatch: function(event, listener, domID) {
312 var returnValue = EventPluginUtils.executeDispatch(event, listener, domID);
313 - if (returnValue === false) {
314 - if (__DEV__) {
313 + if (__DEV__) {
314 + if (typeof returnValue === 'boolean') {
315 monitorCodeUse('react_event_return_false');
316 console.warn(
317 - 'Returning `false` from an event handler will be deprecated in a ' +
318 - 'future release. Instead, manually call e.stopPropagation() or ' +
319 - 'e.preventDefault(), as appropriate.'
317 + 'Returning `false` from an event handler is deprecated and will ' +
318 + 'be ignored in a future release. Instead, manually call ' +
319 + 'e.stopPropagation() or e.preventDefault(), as appropriate.'
320 );
321 }
322 + }
323 +
324 + if (returnValue === false) {
325 event.stopPropagation();
326 event.preventDefault();
327 }