Deprecate 'return false' in event handlers
Charles Marsh committed
Aug 13, 2014 at 21:56 UTC
45f8b52135c8cd9c6a815b25b71b1723439b0c12
4 files changed
+9
-25
docs/_config.yml
+1
-1
@@ -34,4 +34,4 @@ sass:
34
sass_dir: _css
35
gems:
36
- jekyll-redirect-from
37
-react_version: 0.11.1
37
+react_version: 0.12.0-alpha
docs/docs/ref-05-events.md
+5
-1
@@ -10,6 +10,10 @@ next: dom-differences.html
10
11
Your event handlers will be passed instances of `SyntheticEvent`, a cross-browser wrapper around the browser's native event. It has the same interface as the browser's native event, including `stopPropagation()` and `preventDefault()`, except the events work identically across all browsers.
12
13
+> Note:
14
+>
15
+> Prior to v0.12, event handlers could return `false` to stop propagation. This behavior is no longer supported; instead, `stopPropagation()` and `preventDefault()` should be triggered manually.
16
+
17
If you find that you need the underlying browser event for some reason, simply use the `nativeEvent` attribute to get it. Every `SyntheticEvent` object has the following attributes:
18
19
```javascript
@@ -111,7 +115,7 @@ onDragOver onDragStart onDrop onMouseDown onMouseEnter onMouseLeave
115
onMouseMove onMouseOut onMouseOver onMouseUp
116
```
117
114
-Properties:
118
+Properties:
119
120
```javascript
121
boolean altKey
src/browser/__tests__/ReactBrowserEventEmitter-test.js
+3
-7
@@ -253,7 +253,7 @@ describe('ReactBrowserEventEmitter', function() {
253
expect(idCallOrder[0]).toBe(getID(CHILD));
254
});
255
256
- it('should stopPropagation if false is returned', function() {
256
+ it('should continue to propagate if false is returned', function() {
257
ReactBrowserEventEmitter.putListener(
258
getID(CHILD),
259
ON_CLICK_KEY,
@@ -264,14 +264,10 @@ describe('ReactBrowserEventEmitter', function() {
264
ON_CLICK_KEY,
265
recordID.bind(null, getID(PARENT))
266
);
267
- ReactBrowserEventEmitter.putListener(
268
- getID(GRANDPARENT),
269
- ON_CLICK_KEY,
270
- recordID.bind(null, getID(GRANDPARENT))
271
- );
267
ReactTestUtils.Simulate.click(CHILD);
273
- expect(idCallOrder.length).toBe(1);
268
+ expect(idCallOrder.length).toBe(2);
269
expect(idCallOrder[0]).toBe(getID(CHILD));
270
+ expect(idCallOrder[1]).toBe(getID(PARENT));
271
});
272
273
/**
src/browser/eventPlugins/SimpleEventPlugin.js
-16
@@ -299,22 +299,6 @@ var SimpleEventPlugin = {
299
300
eventTypes: eventTypes,
301
302
- /**
303
- * Same as the default implementation, except cancels the event when return
304
- * value is false.
305
- *
306
- * @param {object} Event to be dispatched.
307
- * @param {function} Application-level callback.
308
- * @param {string} domID DOM ID to pass to the callback.
309
- */
310
- executeDispatch: function(event, listener, domID) {
311
- var returnValue = EventPluginUtils.executeDispatch(event, listener, domID);
312
- if (returnValue === false) {
313
- event.stopPropagation();
314
- event.preventDefault();
315
- }
316
- },
317
-
302
/**
303
* @param {string} topLevelType Record from `EventConstants`.
304
* @param {DOMEventTarget} topLevelTarget The listening component root node.