-
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
Fix the "checked" attribute is not initially set on the input #13114
Changes from all commits
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 |
---|---|---|
|
@@ -243,7 +243,7 @@ export function postMountWrapper( | |
node.name = ''; | ||
} | ||
node.defaultChecked = !node.defaultChecked; | ||
node.defaultChecked = !node.defaultChecked; | ||
node.defaultChecked = !!node._wrapperState.initialChecked; | ||
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. Just trying to think through all of the cases here:
node.defaultChecked = true // node.defaultChecked = !node.defaultChecked
node.defaultChecked = true // node.defaultChecked = !!false
node.defaultChecked = true // node.defaultChecked = !node.defaultChecked
node.defaultChecked = false // node.defaultChecked = !!false
This can happen if you just declare a regular text input, ex: In this case, value detachment still needs to occur. An input might switch from node.defaultChecked = true // node.defaultChecked = !node.defaultChecked
node.defaultChecked = false // node.defaultChecked = !!undefined So I think this is good to go. Are there any other cases you can think of? 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. Separately, part of me wonders if However I don't think that's related to this issue, and I'm not sure what existing code relies on that value to be loosely null. 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. Haha, i tried and got a Flow type check error. Cannot assign node._wrapperState.initialChecked to node.defaultChecked because property defaultChecked is missing in object type. 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. One thing at a time. I think this is a great follow-up, but I'd love to get this check attribute fix in first. |
||
if (name !== '') { | ||
node.name = name; | ||
} | ||
|
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.
Just so I can better understand this change, is the reduction of this setAttribute call due to the following case?
checked
ordefaultChecked
aretrue
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.
Sorry. Didn't catch your comment earlier. This makes sense!