Fix double-firing submit events (#12877)

We were adding a listener at the root when we weren't meant to. Blames to e96dc14059.

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>
    );
  }
};
```
This commit is contained in:
Sophie Alpert 2018-05-21 17:47:56 -07:00 committed by GitHub
parent 60853f09f3
commit ad27845ccd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -13,7 +13,9 @@ import {
TOP_CANCEL,
TOP_CLOSE,
TOP_FOCUS,
TOP_RESET,
TOP_SCROLL,
TOP_SUBMIT,
} from './DOMTopLevelEventTypes';
import {
setEnabled,
@ -147,7 +149,7 @@ export function listenTo(
trapCapturedEvent(TOP_CLOSE, mountAt);
}
isListening[TOP_CLOSE] = true;
} else {
} else if (dependency !== TOP_SUBMIT && dependency !== TOP_RESET) {
trapBubbledEvent(dependency, mountAt);
}