Skip to content

Commit

Permalink
Fix <embed> not triggering onLoad (#15614)
Browse files Browse the repository at this point in the history
  • Loading branch information
cherniavskii authored and philipp-spiess committed May 16, 2019
1 parent f961050 commit 4bf88dd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
27 changes: 27 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMEventListener-test.js
Expand Up @@ -446,4 +446,31 @@ describe('ReactDOMEventListener', () => {
document.body.removeChild(container);
}
});

it('should dispatch load for embed elements', () => {
const container = document.createElement('div');
document.body.appendChild(container);

try {
const ref = React.createRef();
const handleLoad = jest.fn();

ReactDOM.render(
<div>
<embed ref={ref} onLoad={handleLoad} />
</div>,
container,
);

ref.current.dispatchEvent(
new ProgressEvent('load', {
bubbles: false,
}),
);

expect(handleLoad).toHaveBeenCalledTimes(1);
} finally {
document.body.removeChild(container);
}
});
});
2 changes: 2 additions & 0 deletions packages/react-dom/src/client/ReactDOMComponent.js
Expand Up @@ -522,6 +522,7 @@ export function setInitialProperties(
switch (tag) {
case 'iframe':
case 'object':
case 'embed':
trapBubbledEvent(TOP_LOAD, domElement);
props = rawProps;
break;
Expand Down Expand Up @@ -916,6 +917,7 @@ export function diffHydratedProperties(
switch (tag) {
case 'iframe':
case 'object':
case 'embed':
trapBubbledEvent(TOP_LOAD, domElement);
break;
case 'video':
Expand Down

0 comments on commit 4bf88dd

Please sign in to comment.