mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
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:
@@ -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]) {
|
||||
|
||||
Reference in New Issue
Block a user