Skip to content

Commit

Permalink
Add onError to ReactDOMImg to complement onLoad
Browse files Browse the repository at this point in the history
  • Loading branch information
syranide committed Feb 13, 2014
1 parent f37474b commit cda1d8c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/browser/dom/components/ReactDOMImg.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ var ReactDOMImg = ReactCompositeComponent.createClass({
},

componentDidMount: function() {
var node = this.getDOMNode();
ReactEventEmitter.trapBubbledEvent(
EventConstants.topLevelTypes.topLoad,
'load',
this.getDOMNode()
node
);
ReactEventEmitter.trapBubbledEvent(
EventConstants.topLevelTypes.topError,
'error',
node
);
}
});
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 @@ -157,6 +157,12 @@ var eventTypes = {
captured: keyOf({onLoadCapture: true})
}
},
error: {
phasedRegistrationNames: {
bubbled: keyOf({onError: true}),
captured: keyOf({onErrorCapture: true})
}
},
// Note: We do not allow listening to mouseOver events. Instead, use the
// onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`.
mouseDown: {
Expand Down Expand Up @@ -260,6 +266,7 @@ var topLevelEventsToDispatchConfig = {
topDragOver: eventTypes.dragOver,
topDragStart: eventTypes.dragStart,
topDrop: eventTypes.drop,
topError: eventTypes.error,
topFocus: eventTypes.focus,
topInput: eventTypes.input,
topKeyDown: eventTypes.keyDown,
Expand Down Expand Up @@ -327,6 +334,7 @@ var SimpleEventPlugin = {
switch (topLevelType) {
case topLevelTypes.topInput:
case topLevelTypes.topLoad:
case topLevelTypes.topError:
case topLevelTypes.topReset:
case topLevelTypes.topSubmit:
// HTML Events
Expand Down
1 change: 1 addition & 0 deletions src/event/EventConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ var topLevelTypes = keyMirror({
topDragOver: null,
topDragStart: null,
topDrop: null,
topError: null,
topFocus: null,
topInput: null,
topKeyDown: null,
Expand Down

0 comments on commit cda1d8c

Please sign in to comment.