-
Notifications
You must be signed in to change notification settings - Fork 48.5k
fix textarea value
of number 0
#274
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
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 |
---|---|---|
|
@@ -45,13 +45,36 @@ describe('ReactDOMInput', function() { | |
expect(node.value).toBe('0'); | ||
}); | ||
|
||
it('should display "" for `defaultValue` of `false`', function() { | ||
var stub = <input type="text" defaultValue={false} />; | ||
var node = renderTextInput(stub); | ||
|
||
expect(node.value).toBe(''); | ||
}); | ||
|
||
it('should display `value` of number 0', function() { | ||
var stub = <input type="text" value={0} />; | ||
var node = renderTextInput(stub); | ||
|
||
expect(node.value).toBe('0'); | ||
}); | ||
|
||
it('should display "" for `value` of `false`', function() { | ||
var stub = <input type="text" value={false} />; | ||
var node = renderTextInput(stub); | ||
|
||
expect(node.value).toBe(''); | ||
}); | ||
|
||
it('should properly control a value of number `0`', function() { | ||
var stub = <input type="text" value={0} />; | ||
var node = renderTextInput(stub); | ||
|
||
node.value = 'giraffe'; | ||
ReactTestUtils.Simulate.input(node); | ||
expect(node.value).toBe('0'); | ||
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. Curious why the 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. It's a controlled component with no onChange handler… (note I'm changing the actual value, not the 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. So 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. 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, the 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. I'm trying to upgrade the |
||
}); | ||
|
||
it('should control radio buttons', function() { | ||
var RadioGroup = React.createClass({ | ||
render: function() { | ||
|
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.
Obviously the old code here differs from textarea already, but perhaps this was intentional so that
false
becomes''
; generally in React you can writeflag && <Component />
where nothing is inserted ifflag
is false so here perhaps we want to support<input value={flag && val} />
here too.