Skip to content

Commit 136bea6

Browse files
author
Wensheng Xu
committed
Fix - issue #12765 / use wrapperState.initialChecked simplify the DOM
operations.
1 parent 3c670a4 commit 136bea6

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

packages/react-dom/src/__tests__/ReactDOMInput-test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,7 @@ describe('ReactDOMInput', () => {
739739
const cNode = stub.refs.c;
740740

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

756756
// The original 'checked' attribute should be unchanged
757-
expect(aNode.getAttribute('checked')).toBe(null);
757+
expect(aNode.getAttribute('checked')).toBe('checked');
758758
expect(bNode.getAttribute('checked')).toBe(null);
759759
expect(cNode.getAttribute('checked')).toBe('checked');
760760

packages/react-dom/src/client/ReactDOMFiberInput.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ export function postMountWrapper(
245245
node.defaultChecked = !node.defaultChecked;
246246
node.defaultChecked = !node.defaultChecked;
247247
// Set the "checked" attribute initially.
248-
if (props.hasOwnProperty('defaultChecked') && !!props.defaultChecked) {
248+
if (node._wrapperState.initialChecked) {
249249
node.setAttribute('checked', 'checked');
250250
}
251251
if (name !== '') {

0 commit comments

Comments
 (0)