@samitouri / QOS-React / commits / ad27845ccd

Fix double-firing submit events (#12877)

We were adding a listener at the root when we weren't meant to. Blames to e96dc140599363029bd05565d58bcd4a432db370. This now alerts once (at FORM) instead of twice (at FORM, #document): ``` var Hello = class extends React.Component { render() { return ( <form onSubmit={(e) => {e.preventDefault(); alert('hi ' + e.nativeEvent.currentTarget.nodeName);}}> <button>hi</button> </form> ); } }; ```

Sophie Alpert committed May 21, 2018 at 17:47 UTC ad27845ccd4fe34189514db23b645d7ab2213496
1 file changed +3 -1
packages/react-dom/src/events/ReactBrowserEventEmitter.js
+3 -1
@@ -13,7 +13,9 @@ import {
13 TOP_CANCEL,
14 TOP_CLOSE,
15 TOP_FOCUS,
16 + TOP_RESET,
17 TOP_SCROLL,
18 + TOP_SUBMIT,
19 } from './DOMTopLevelEventTypes';
20 import {
21 setEnabled,
@@ -147,7 +149,7 @@ export function listenTo(
149 trapCapturedEvent(TOP_CLOSE, mountAt);
150 }
151 isListening[TOP_CLOSE] = true;
150 - } else {
152 + } else if (dependency !== TOP_SUBMIT && dependency !== TOP_RESET) {
153 trapBubbledEvent(dependency, mountAt);
154 }
155