Add onError to ReactDOMImg to complement onLoad

This commit is contained in:
Andreas Svensson
2014-01-09 17:23:29 +01:00
parent f37474b75b
commit cda1d8c779
3 changed files with 16 additions and 1 deletions
+7 -1
View File
@@ -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
);
}
});
@@ -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: {
@@ -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,
@@ -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
+1
View File
@@ -44,6 +44,7 @@ var topLevelTypes = keyMirror({
topDragOver: null,
topDragStart: null,
topDrop: null,
topError: null,
topFocus: null,
topInput: null,
topKeyDown: null,