Skip to content

Commit

Permalink
Fix - issue #12765 / use wrapperState.initialChecked simplify the DOM
Browse files Browse the repository at this point in the history
operations.
  • Loading branch information
Wensheng Xu committed Jun 28, 2018
1 parent 3c670a4 commit 136bea6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/react-dom/src/__tests__/ReactDOMInput-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ describe('ReactDOMInput', () => {
const cNode = stub.refs.c;

expect(aNode.checked).toBe(true);
expect(bNode.getAttribute('checked')).toBe(null);
expect(aNode.getAttribute('checked')).toBe('checked');
expect(bNode.checked).toBe(false);
expect(bNode.getAttribute('checked')).toBe(null);
// c is in a separate form and shouldn't be affected at all here
Expand All @@ -754,7 +754,7 @@ describe('ReactDOMInput', () => {
expect(cNode.checked).toBe(true);

// The original 'checked' attribute should be unchanged
expect(aNode.getAttribute('checked')).toBe(null);
expect(aNode.getAttribute('checked')).toBe('checked');
expect(bNode.getAttribute('checked')).toBe(null);
expect(cNode.getAttribute('checked')).toBe('checked');

Expand Down
2 changes: 1 addition & 1 deletion packages/react-dom/src/client/ReactDOMFiberInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export function postMountWrapper(
node.defaultChecked = !node.defaultChecked;
node.defaultChecked = !node.defaultChecked;
// Set the "checked" attribute initially.
if (props.hasOwnProperty('defaultChecked') && !!props.defaultChecked) {
if (node._wrapperState.initialChecked) {
node.setAttribute('checked', 'checked');
}
if (name !== '') {
Expand Down

0 comments on commit 136bea6

Please sign in to comment.