Skip to content

Commit

Permalink
Merge pull request #1048 from spicyj/form-onreset
Browse files Browse the repository at this point in the history
Add onReset event for forms
  • Loading branch information
zpao committed Feb 11, 2014
2 parents 8cf5882 + 30fd3a3 commit 4974734
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/browser/dom/components/ReactDOMForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ var ReactDOMForm = ReactCompositeComponent.createClass({
},

componentDidMount: function() {
ReactEventEmitter.trapBubbledEvent(
EventConstants.topLevelTypes.topReset,
'reset',
this.getDOMNode()
);
ReactEventEmitter.trapBubbledEvent(
EventConstants.topLevelTypes.topSubmit,
'submit',
Expand Down
8 changes: 8 additions & 0 deletions src/browser/eventPlugins/SimpleEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ var eventTypes = {
captured: keyOf({onPasteCapture: true})
}
},
reset: {
phasedRegistrationNames: {
bubbled: keyOf({onReset: true}),
captured: keyOf({onResetCapture: true})
}
},
scroll: {
phasedRegistrationNames: {
bubbled: keyOf({onScroll: true}),
Expand Down Expand Up @@ -266,6 +272,7 @@ var topLevelEventsToDispatchConfig = {
topMouseOver: eventTypes.mouseOver,
topMouseUp: eventTypes.mouseUp,
topPaste: eventTypes.paste,
topReset: eventTypes.reset,
topScroll: eventTypes.scroll,
topSubmit: eventTypes.submit,
topTouchCancel: eventTypes.touchCancel,
Expand Down Expand Up @@ -320,6 +327,7 @@ var SimpleEventPlugin = {
switch (topLevelType) {
case topLevelTypes.topInput:
case topLevelTypes.topLoad:
case topLevelTypes.topReset:
case topLevelTypes.topSubmit:
// HTML Events
// @see http://www.w3.org/TR/html5/index.html#events-0
Expand Down
1 change: 1 addition & 0 deletions src/event/EventConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var topLevelTypes = keyMirror({
topMouseOver: null,
topMouseUp: null,
topPaste: null,
topReset: null,
topScroll: null,
topSelectionChange: null,
topSubmit: null,
Expand Down

0 comments on commit 4974734

Please sign in to comment.