diff --git a/src/renderers/dom/shared/ReactDOMComponent.js b/src/renderers/dom/shared/ReactDOMComponent.js index 5885c1f6d0575..cff52250c4494 100644 --- a/src/renderers/dom/shared/ReactDOMComponent.js +++ b/src/renderers/dom/shared/ReactDOMComponent.js @@ -359,7 +359,15 @@ function trapBubbledEventsLocal() { ); } } - + break; + case 'source': + inst._wrapperState.listeners = [ + ReactBrowserEventEmitter.trapBubbledEvent( + EventConstants.topLevelTypes.topError, + 'error', + node + ), + ]; break; case 'img': inst._wrapperState.listeners = [ @@ -535,6 +543,7 @@ ReactDOMComponent.Mixin = { case 'img': case 'link': case 'object': + case 'source': case 'video': this._wrapperState = { listeners: null, @@ -1124,6 +1133,7 @@ ReactDOMComponent.Mixin = { case 'img': case 'link': case 'object': + case 'source': case 'video': var listeners = this._wrapperState.listeners; if (listeners) { diff --git a/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js b/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js index 73a2dfe95a472..e52d4e0766a70 100644 --- a/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js +++ b/src/renderers/dom/shared/__tests__/ReactDOMComponent-test.js @@ -723,6 +723,26 @@ describe('ReactDOMComponent', function() { }; }); + it('should work error event on element', function() { + spyOn(console, 'error'); + var container = document.createElement('div'); + ReactDOM.render( + , + container + ); + + var errorEvent = document.createEvent('Event'); + errorEvent.initEvent('error', false, false); + container.getElementsByTagName('source')[0].dispatchEvent(errorEvent); + + expect(console.error.calls.count()).toBe(1); + expect(console.error.calls.argsFor(0)[0]).toContain( + 'onError called' + ); + }); + it('should not duplicate uppercased selfclosing tags', function() { var Container = React.createClass({ render: function() {