-
Notifications
You must be signed in to change notification settings - Fork 46.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use defaultValue instead of setAttribute('value') (#11534)
* Use defaultValue instead of setAttribute('value') This commit replaces the method of synchronizing an input's value attribute from using setAttribute to assigning defaultValue. This has several benefits: - Fixes issue where IE10+ and Edge password icon disappears (#7328) - Fixes issue where toggling input types hides display value on dates in Safari (unreported) - Removes mutationMethod behaviors from DOMPropertyOperations * initialValue in Input wrapperState is always a string * The value property is assigned before the value attribute. Fix related tests. * Remove initial value tests in ReactDOMInput I added these tests after removing the `value` mutation method. However they do not add any additional value over existing tests. * Improve clarity of value checks in ReactDOMInput.postMountWrapper * Remove value and defaultValue from InputWithWrapperState type They are already included in the type definition for HTMLInputElement * Inline stringification of value in ReactDOMInput Avoids eagier stringification and makes usage more consistent. * Use consistent value/defaultValue presence in postMountHook Other methods in ReactDOMInput check for null instead of hasOwnProperty. * Add missing semicolon * Remove unused value argument in ReactDOMInput test * Address cases where a value switches to undefined When a controlled input value switches to undefined, it reverts back to the initial state of the controlled input. We didn't have test coverage for this case, so I've added two describe blocks to cover both null and undefined.
- Loading branch information
Showing
6 changed files
with
147 additions
and
133 deletions.
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
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
Oops, something went wrong.