Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing test for radio checked with changing names #26588

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMInput-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,28 @@ describe('ReactDOMInput', () => {
expect(firstRadioNode.checked).toBe(true);
});

it("shouldn't get tricked by changing radio names, part 2", () => {
ReactDOM.render(
<div>
<input type="radio" name="a" value="1" checked={true} onChange={() => {}} />
<input type="radio" name="a" value="2" checked={false} onChange={() => {}} />
</div>,
container
);
expect(container.querySelector('input[name="a"][value="1"]').checked).toBe(true);
expect(container.querySelector('input[name="a"][value="2"]').checked).toBe(false);

ReactDOM.render(
<div>
<input type="radio" name="a" value="1" checked={true} onChange={() => {}} />
<input type="radio" name="b" value="2" checked={true} onChange={() => {}} />
</div>,
container
);
expect(container.querySelector('input[name="a"][value="1"]').checked).toBe(true);
expect(container.querySelector('input[name="b"][value="2"]').checked).toBe(true);
});

it('should control radio buttons if the tree updates during render', () => {
const sharedParent = container;
const container1 = document.createElement('div');
Expand Down