-
Notifications
You must be signed in to change notification settings - Fork 45.7k
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
Fix a crash when using dynamic children in <option> tag #13261
Changes from 6 commits
388028e
f829340
73697ef
65691b6
9ca2085
931417b
485d8db
a6a8d1c
7ccf3ce
e614dbf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -545,6 +545,48 @@ describe('ReactDOMSelect', () => { | |
expect(node.options[2].selected).toBe(false); // gorilla | ||
}); | ||
|
||
it('should not fail', () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is very vague. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, It's some temporary "name" until we get a full working version. Have you taken a look on There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about this description: "Options with stateful children; it should change its state properly and shouldn't fail" |
||
const container = document.createElement('div'); | ||
|
||
let node; | ||
|
||
function App({value}) { | ||
return ( | ||
<select value={value} ref={n => (node = n)} onChange={noop}> | ||
<option key="monkey" value="monkey"> | ||
A monkey {value === 'monkey' ? 'is chosen' : null}! | ||
</option> | ||
<option key="giraffe" value="giraffe"> | ||
A giraffe {value === 'giraffe' && 'is chosen'}! | ||
</option> | ||
<option key="gorilla" value="gorilla"> | ||
A gorilla {value === 'gorilla' && 'is chosen'}! | ||
</option> | ||
</select> | ||
); | ||
} | ||
|
||
ReactDOM.render( | ||
<App value={'monkey'} />, | ||
container, | ||
); | ||
|
||
expect(node.options[0].selected).toBe(true); // monkey | ||
expect(node.options[1].selected).toBe(false); // giraffe | ||
expect(node.options[2].selected).toBe(false); // gorilla | ||
|
||
|
||
ReactDOM.render( | ||
<App value={'giraffe'} />, | ||
container, | ||
); | ||
|
||
expect(node.options[0].selected).toBe(false); // monkey | ||
expect(node.options[1].selected).toBe(true); // giraffe | ||
expect(node.options[2].selected).toBe(false); // gorilla | ||
|
||
}); | ||
|
||
it('should warn if value is null', () => { | ||
expect(() => | ||
ReactTestUtils.renderIntoDocument( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a behavior change and I'm not sure how to avoid this with this solution. But it's only warning, so shouldn't be critical.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is okay. Particularly since the problem is still identified in the message (even if the nest doesn't show up).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aweary or @gaearon Do you anticipate any problems with changing this warning text?