diff --git a/src/dom/components/ReactDOMInput.js b/src/dom/components/ReactDOMInput.js
index 7b45aef515..2e22c4ffe5 100644
--- a/src/dom/components/ReactDOMInput.js
+++ b/src/dom/components/ReactDOMInput.js
@@ -48,7 +48,7 @@ var ReactDOMInput = ReactCompositeComponent.createClass({
getInitialState: function() {
return {
checked: this.props.defaultChecked || false,
- value: this.props.defaultValue || ''
+ value: this.props.defaultValue != null ? this.props.defaultValue : ''
};
},
diff --git a/src/dom/components/ReactDOMTextarea.js b/src/dom/components/ReactDOMTextarea.js
index 2d1beb7795..6fe8992b37 100644
--- a/src/dom/components/ReactDOMTextarea.js
+++ b/src/dom/components/ReactDOMTextarea.js
@@ -77,7 +77,9 @@ var ReactDOMTextarea = ReactCompositeComponent.createClass({
);
defaultValue = '' + children;
}
- defaultValue = defaultValue || '';
+ if (defaultValue == null) {
+ defaultValue = '';
+ }
return {
// We save the initial value so that `ReactNativeComponent` doesn't update
// `textContent` (unnecessary since we update value).
diff --git a/src/dom/components/__tests__/ReactDOMInput-test.js b/src/dom/components/__tests__/ReactDOMInput-test.js
new file mode 100644
index 0000000000..877b400080
--- /dev/null
+++ b/src/dom/components/__tests__/ReactDOMInput-test.js
@@ -0,0 +1,55 @@
+/**
+ * Copyright 2013 Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @jsx React.DOM
+ * @emails react-core
+ */
+
+"use strict";
+
+/*jshint evil:true */
+
+describe('ReactDOMInput', function() {
+ var React;
+ var ReactTestUtils;
+
+ var renderTextInput;
+
+ beforeEach(function() {
+ React = require('React');
+ ReactTestUtils = require('ReactTestUtils');
+
+ renderTextInput = function(component) {
+ var stub = ReactTestUtils.renderIntoDocument(component);
+ var node = stub.getDOMNode();
+ return node;
+ };
+ });
+
+ it('should display `defaultValue` of number 0', function() {
+ var stub = ;
+ var node = renderTextInput(stub);
+
+ expect(node.value).toBe('0');
+ });
+
+ it('should display `value` of number 0', function() {
+ var stub = ;
+ var node = renderTextInput(stub);
+
+ expect(node.value).toBe('0');
+ });
+
+});
diff --git a/src/dom/components/__tests__/ReactDOMTextarea-test.js b/src/dom/components/__tests__/ReactDOMTextarea-test.js
index 456a8e63c1..d4a35014fe 100644
--- a/src/dom/components/__tests__/ReactDOMTextarea-test.js
+++ b/src/dom/components/__tests__/ReactDOMTextarea-test.js
@@ -51,6 +51,13 @@ describe('ReactDOMTextarea', function() {
expect(node.value).toEqual('giraffe');
});
+ it('should display `defaultValue` of number 0', function() {
+ var stub = ;
+ var node = renderTextarea(stub);
+
+ expect(node.value).toBe('0');
+ });
+
it('should allow setting `value`', function() {
var stub = ;
var node = renderTextarea(stub);
@@ -61,6 +68,13 @@ describe('ReactDOMTextarea', function() {
expect(node.value).toEqual('gorilla');
});
+ it('should display `value` of number 0', function() {
+ var stub = ;
+ var node = renderTextarea(stub);
+
+ expect(node.value).toBe('0');
+ });
+
it('should treat children like `defaultValue`', function() {
spyOn(console, 'warn');