Skip to content

Commit

Permalink
Test add testing for video muted
Browse files Browse the repository at this point in the history
  • Loading branch information
atnpcg committed Oct 24, 2020
1 parent be8b1d0 commit d5b38d1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMComponent-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,15 @@ describe('ReactDOMComponent', () => {
}
});

it('video muted prop should show as an attribute', () => {
const container = document.createElement('div');
ReactDOM.render(
<video src="http://example.org/video" muted={true} />,
container,
);
expect(container.firstChild.hasAttribute('muted')).toBe(true);
});

it('should not duplicate uppercased selfclosing tags', () => {
class Container extends React.Component {
render() {
Expand Down
10 changes: 9 additions & 1 deletion packages/react-dom/src/client/DOMPropertyOperations.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,15 @@ export function setValueForProperty(
} else {
// Contrary to `setAttribute`, object properties are properly
// `toString`ed by IE8/9.
(node: any)[propertyName] = value;
// props that needs an attribute to work (mute) needs to wait for the attribute to be rendered first so it won't cause
// a change on the property
if (propertyMustUseAttribute) {
setTimeout(() => {
(node: any)[propertyName] = value;
}, 0);
} else {
(node: any)[propertyName] = value;
}
}
if (!propertyMustUseAttribute) {
return;
Expand Down

0 comments on commit d5b38d1

Please sign in to comment.