ReactTransitions: Don't animate undefined children
Simon Højberg committed
Nov 13, 2013 at 20:54 UTC
acbddd26413a20afe48ca6ad681c9229933ba848
2 files changed
+20
-6
src/addons/transitions/ReactTransitionGroup.js
+5
@@ -44,6 +44,11 @@ var ReactTransitionGroupMixin = {
44
'getTransitionConfig() method.'
45
);
46
47
+ // don't animate undefined children
48
+ if (typeof sourceChildren === 'undefined') {
49
+ return;
50
+ }
51
+
52
var children = {};
53
var childMapping = ReactTransitionKeySet.getChildMapping(sourceChildren);
54
var transitionConfig = this.getTransitionConfig();
src/addons/transitions/__tests__/ReactTransitionGroup-test.js
+15
-6
@@ -26,18 +26,18 @@ var mocks;
26
// Most of the real functionality is covered in other unit tests, this just
27
// makes sure we're wired up correctly.
28
describe('ReactTransitionGroup', function() {
29
+ var container;
30
+
31
beforeEach(function() {
32
React = require('React');
33
ReactTransitionGroup = require('ReactTransitionGroup');
34
mocks = require('mocks');
35
+
36
+ container = document.createElement('div');
37
});
38
39
it('should warn after time with no transitionend', function() {
36
- var container;
37
- var a;
38
-
39
- container = document.createElement('div');
40
- a = React.renderComponent(
40
+ var a = React.renderComponent(
41
<ReactTransitionGroup transitionName="yolo">
42
<span key="one" id="one" />
43
</ReactTransitionGroup>,
@@ -65,7 +65,6 @@ describe('ReactTransitionGroup', function() {
65
});
66
67
it('should keep both sets of DOM nodes around', function() {
68
- var container = document.createElement('div');
68
var a = React.renderComponent(
69
<ReactTransitionGroup transitionName="yolo">
70
<span key="one" id="one" />
@@ -83,4 +82,14 @@ describe('ReactTransitionGroup', function() {
82
expect(a.getDOMNode().childNodes[0].id).toBe('two');
83
expect(a.getDOMNode().childNodes[1].id).toBe('one');
84
});
85
+
86
+ describe('with an undefined child', function () {
87
+ it('should fail silently', function () {
88
+ var a = React.renderComponent(
89
+ <ReactTransitionGroup transitionName="yolo">
90
+ </ReactTransitionGroup>,
91
+ container
92
+ );
93
+ });
94
+ });
95
});