Merge pull request #6677 from zpao/dont-warn-css-0-string

Don't warn when style value is '0'
(cherry picked from commit 5c6f9d31bd)
This commit is contained in:
Paul O’Shannessy
2016-05-26 20:05:32 -07:00
parent 2f4c61d1be
commit e8a8d005f0
2 changed files with 15 additions and 1 deletions
@@ -203,6 +203,18 @@ describe('ReactDOMComponent', function() {
expect(console.error.calls.count()).toBe(2);
});
it('should not warn for "0" as a unitless style value', function() {
spyOn(console, 'error');
var Component = React.createClass({
render: function() {
return <div style={{margin: '0'}} />;
},
});
ReactTestUtils.renderIntoDocument(<Component />);
expect(console.error.calls.length).toBe(0);
});
it('should warn nicely about NaN in style', function() {
spyOn(console, 'error');
@@ -51,7 +51,9 @@ function dangerousStyleValue(name, value, component) {
if (typeof value === 'string') {
if (__DEV__) {
if (component) {
// Allow '0' to pass through without warning. 0 is already special and
// doesn't require units, so we don't need to warn about it.
if (component && value !== '0') {
var owner = component._currentElement._owner;
var ownerName = owner ? owner.getName() : null;
if (ownerName && !styleWarnings[ownerName]) {