Deprecate 'return false' in event handlers
This commit is contained in:
parent
5ca9e193ee
commit
45f8b52135
|
@ -34,4 +34,4 @@ sass:
|
||||||
sass_dir: _css
|
sass_dir: _css
|
||||||
gems:
|
gems:
|
||||||
- jekyll-redirect-from
|
- jekyll-redirect-from
|
||||||
react_version: 0.11.1
|
react_version: 0.12.0-alpha
|
||||||
|
|
|
@ -10,6 +10,10 @@ next: dom-differences.html
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
> Note:
|
||||||
|
>
|
||||||
|
> 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.
|
||||||
|
|
||||||
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:
|
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:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
|
@ -111,7 +115,7 @@ onDragOver onDragStart onDrop onMouseDown onMouseEnter onMouseLeave
|
||||||
onMouseMove onMouseOut onMouseOver onMouseUp
|
onMouseMove onMouseOut onMouseOver onMouseUp
|
||||||
```
|
```
|
||||||
|
|
||||||
Properties:
|
Properties:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
boolean altKey
|
boolean altKey
|
||||||
|
|
|
@ -253,7 +253,7 @@ describe('ReactBrowserEventEmitter', function() {
|
||||||
expect(idCallOrder[0]).toBe(getID(CHILD));
|
expect(idCallOrder[0]).toBe(getID(CHILD));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should stopPropagation if false is returned', function() {
|
it('should continue to propagate if false is returned', function() {
|
||||||
ReactBrowserEventEmitter.putListener(
|
ReactBrowserEventEmitter.putListener(
|
||||||
getID(CHILD),
|
getID(CHILD),
|
||||||
ON_CLICK_KEY,
|
ON_CLICK_KEY,
|
||||||
|
@ -264,14 +264,10 @@ describe('ReactBrowserEventEmitter', function() {
|
||||||
ON_CLICK_KEY,
|
ON_CLICK_KEY,
|
||||||
recordID.bind(null, getID(PARENT))
|
recordID.bind(null, getID(PARENT))
|
||||||
);
|
);
|
||||||
ReactBrowserEventEmitter.putListener(
|
|
||||||
getID(GRANDPARENT),
|
|
||||||
ON_CLICK_KEY,
|
|
||||||
recordID.bind(null, getID(GRANDPARENT))
|
|
||||||
);
|
|
||||||
ReactTestUtils.Simulate.click(CHILD);
|
ReactTestUtils.Simulate.click(CHILD);
|
||||||
expect(idCallOrder.length).toBe(1);
|
expect(idCallOrder.length).toBe(2);
|
||||||
expect(idCallOrder[0]).toBe(getID(CHILD));
|
expect(idCallOrder[0]).toBe(getID(CHILD));
|
||||||
|
expect(idCallOrder[1]).toBe(getID(PARENT));
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -299,22 +299,6 @@ var SimpleEventPlugin = {
|
||||||
|
|
||||||
eventTypes: eventTypes,
|
eventTypes: eventTypes,
|
||||||
|
|
||||||
/**
|
|
||||||
* Same as the default implementation, except cancels the event when return
|
|
||||||
* value is false.
|
|
||||||
*
|
|
||||||
* @param {object} Event to be dispatched.
|
|
||||||
* @param {function} Application-level callback.
|
|
||||||
* @param {string} domID DOM ID to pass to the callback.
|
|
||||||
*/
|
|
||||||
executeDispatch: function(event, listener, domID) {
|
|
||||||
var returnValue = EventPluginUtils.executeDispatch(event, listener, domID);
|
|
||||||
if (returnValue === false) {
|
|
||||||
event.stopPropagation();
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} topLevelType Record from `EventConstants`.
|
* @param {string} topLevelType Record from `EventConstants`.
|
||||||
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
* @param {DOMEventTarget} topLevelTarget The listening component root node.
|
||||||
|
|
Loading…
Reference in New Issue