-
Notifications
You must be signed in to change notification settings - Fork 47k
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
Remove initOption special case #26595
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,13 @@ | |
|
||
'use strict'; | ||
|
||
// Fix JSDOM. setAttribute is supposed to throw on things that can't be implicitly toStringed. | ||
const setAttribute = Element.prototype.setAttribute; | ||
Element.prototype.setAttribute = function (name, value) { | ||
// eslint-disable-next-line react-internal/safe-string-coercion | ||
return setAttribute.call(this, name, '' + value); | ||
}; | ||
|
||
describe('ReactDOMSelect', () => { | ||
let React; | ||
let ReactDOM; | ||
|
@@ -849,7 +856,7 @@ describe('ReactDOMSelect', () => { | |
}); | ||
|
||
describe('When given a Symbol value', () => { | ||
it('treats initial Symbol value as an empty string', () => { | ||
it('treats initial Symbol value as missing', () => { | ||
let node; | ||
|
||
expect(() => { | ||
|
@@ -862,10 +869,10 @@ describe('ReactDOMSelect', () => { | |
); | ||
}).toErrorDev('Invalid value for prop `value`'); | ||
|
||
expect(node.value).toBe(''); | ||
expect(node.value).toBe('A Symbol!'); | ||
}); | ||
|
||
it('treats updated Symbol value as an empty string', () => { | ||
it('treats updated Symbol value as missing', () => { | ||
let node; | ||
|
||
expect(() => { | ||
|
@@ -888,7 +895,7 @@ describe('ReactDOMSelect', () => { | |
</select>, | ||
); | ||
|
||
expect(node.value).toBe(''); | ||
expect(node.value).toBe('A Symbol!'); | ||
}); | ||
|
||
it('treats initial Symbol defaultValue as an empty string', () => { | ||
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. These defaultValue tests are bad tests because they test what the current selection is with the first option, but since the first option is selected when there is no match, they don't fail if it just doesn't match. |
||
|
@@ -904,7 +911,7 @@ describe('ReactDOMSelect', () => { | |
); | ||
}).toErrorDev('Invalid value for prop `value`'); | ||
|
||
expect(node.value).toBe(''); | ||
expect(node.value).toBe('A Symbol!'); | ||
}); | ||
|
||
it('treats updated Symbol defaultValue as an empty string', () => { | ||
|
@@ -930,12 +937,12 @@ describe('ReactDOMSelect', () => { | |
</select>, | ||
); | ||
|
||
expect(node.value).toBe(''); | ||
expect(node.value).toBe('A Symbol!'); | ||
}); | ||
}); | ||
|
||
describe('When given a function value', () => { | ||
it('treats initial function value as an empty string', () => { | ||
it('treats initial function value as missing', () => { | ||
let node; | ||
|
||
expect(() => { | ||
|
@@ -948,7 +955,7 @@ describe('ReactDOMSelect', () => { | |
); | ||
}).toErrorDev('Invalid value for prop `value`'); | ||
|
||
expect(node.value).toBe(''); | ||
expect(node.value).toBe('A function!'); | ||
}); | ||
|
||
it('treats initial function defaultValue as an empty string', () => { | ||
|
@@ -964,7 +971,7 @@ describe('ReactDOMSelect', () => { | |
); | ||
}).toErrorDev('Invalid value for prop `value`'); | ||
|
||
expect(node.value).toBe(''); | ||
expect(node.value).toBe('A function!'); | ||
}); | ||
|
||
it('treats updated function value as an empty string', () => { | ||
|
@@ -990,7 +997,7 @@ describe('ReactDOMSelect', () => { | |
</select>, | ||
); | ||
|
||
expect(node.value).toBe(''); | ||
expect(node.value).toBe('A function!'); | ||
}); | ||
|
||
it('treats updated function defaultValue as an empty string', () => { | ||
|
@@ -1016,7 +1023,7 @@ describe('ReactDOMSelect', () => { | |
</select>, | ||
); | ||
|
||
expect(node.value).toBe(''); | ||
expect(node.value).toBe('A function!'); | ||
}); | ||
}); | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 little hacky but it's making the TemporalLike objects throw without us explicitly tostringing in React which we shouldn't need to, since there can be Trusted Types involved. Maybe a newer JSDOM would help.
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.
Can we unset this in an afterAll so it's just for this file? Or move it to setupEnvironment.js (or setupTests.js? I don't know what the difference is)?
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.
Isn't it a new document for every test suite anyway? I think we rely on that anyway.
I wanted to colocate this fix so that we can choose to fix the tests instead if we need to.