mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Allow falsy values in statics
We found that the component would break if we set any statics with the
value 0. It turns out @chenglou already ran into this with
d71736b3ed but the statics code was copied
earlier, and still has this falsy check. Made the same change, updated
the unittest.
This commit is contained in:
committed by
Paul O’Shannessy
parent
06f762da77
commit
13aa8d37e6
@@ -503,7 +503,7 @@ function mixStaticSpecIntoComponent(ConvenienceConstructor, statics) {
|
||||
}
|
||||
for (var name in statics) {
|
||||
var property = statics[name];
|
||||
if (!statics.hasOwnProperty(name) || !property) {
|
||||
if (!statics.hasOwnProperty(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1007,7 +1007,10 @@ describe('ReactCompositeComponent', function() {
|
||||
it('should support statics', function() {
|
||||
var Component = React.createClass({
|
||||
statics: {
|
||||
abc: 'def'
|
||||
abc: 'def',
|
||||
def: 0,
|
||||
ghi: null,
|
||||
jkl: 'mno'
|
||||
},
|
||||
|
||||
render: function() {
|
||||
@@ -1018,6 +1021,12 @@ describe('ReactCompositeComponent', function() {
|
||||
ReactTestUtils.renderIntoDocument(instance);
|
||||
expect(instance.constructor.abc).toBe('def');
|
||||
expect(Component.abc).toBe('def');
|
||||
expect(instance.constructor.def).toBe(0);
|
||||
expect(Component.def).toBe(0);
|
||||
expect(instance.constructor.ghi).toBe(null);
|
||||
expect(Component.ghi).toBe(null);
|
||||
expect(instance.constructor.jkl).toBe('mno');
|
||||
expect(Component.jkl).toBe('mno');
|
||||
});
|
||||
|
||||
it('should support statics in mixins', function() {
|
||||
|
||||
Reference in New Issue
Block a user