Skip to content

Commit

Permalink
Add support for "invalid" event within Form elements
Browse files Browse the repository at this point in the history
  • Loading branch information
tomduncalf committed Oct 15, 2015
1 parent da11356 commit 2c498f1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/renderers/dom/client/eventPlugins/SimpleEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,12 @@ var eventTypes = {
captured: keyOf({onInputCapture: true}),
},
},
invalid: {
phasedRegistrationNames: {
bubbled: keyOf({onInvalid: true}),
captured: keyOf({onInvalidCapture: true}),
},
},
keyDown: {
phasedRegistrationNames: {
bubbled: keyOf({onKeyDown: true}),
Expand Down Expand Up @@ -404,6 +410,7 @@ var topLevelEventsToDispatchConfig = {
topError: eventTypes.error,
topFocus: eventTypes.focus,
topInput: eventTypes.input,
topInvalid: eventTypes.invalid,
topKeyDown: eventTypes.keyDown,
topKeyPress: eventTypes.keyPress,
topKeyUp: eventTypes.keyUp,
Expand Down Expand Up @@ -480,6 +487,7 @@ var SimpleEventPlugin = {
case topLevelTypes.topEnded:
case topLevelTypes.topError:
case topLevelTypes.topInput:
case topLevelTypes.topInvalid:
case topLevelTypes.topLoad:
case topLevelTypes.topLoadedData:
case topLevelTypes.topLoadedMetadata:
Expand Down
14 changes: 14 additions & 0 deletions src/renderers/dom/shared/ReactDOMComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,17 @@ function trapBubbledEventsLocal() {
),
];
break;
case 'input':
case 'select':
case 'textarea':
inst._wrapperState.listeners = [
ReactBrowserEventEmitter.trapBubbledEvent(
EventConstants.topLevelTypes.topInvalid,
'invalid',
node
),
];
break;
}
}

Expand Down Expand Up @@ -557,6 +568,9 @@ ReactDOMComponent.Mixin = {
case 'form':
case 'video':
case 'audio':
case 'input':
case 'select':
case 'textarea':
this._wrapperState = {
listeners: null,
};
Expand Down
1 change: 1 addition & 0 deletions src/renderers/shared/event/EventConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ var topLevelTypes = keyMirror({
topError: null,
topFocus: null,
topInput: null,
topInvalid: null,
topKeyDown: null,
topKeyPress: null,
topKeyUp: null,
Expand Down

0 comments on commit 2c498f1

Please sign in to comment.