ReactTransitionGroup: Fix moving from falsey child

See http://stackoverflow.com/q/23510413/49485.

Test Plan: grunt fasttest
This commit is contained in:
Ben Alpert
2014-05-07 09:54:23 -03:00
parent 486b3c0bc5
commit 5c9224145e
2 changed files with 22 additions and 2 deletions
@@ -62,14 +62,16 @@ var ReactTransitionGroup = React.createClass({
for (key in nextChildMapping) {
var hasPrev = prevChildMapping && prevChildMapping.hasOwnProperty(key);
if (!hasPrev && !this.currentlyTransitioningKeys[key]) {
if (nextChildMapping[key] && !hasPrev &&
!this.currentlyTransitioningKeys[key]) {
this.keysToEnter.push(key);
}
}
for (key in prevChildMapping) {
var hasNext = nextChildMapping && nextChildMapping.hasOwnProperty(key);
if (!hasNext && !this.currentlyTransitioningKeys[key]) {
if (prevChildMapping[key] && !hasNext &&
!this.currentlyTransitioningKeys[key]) {
this.keysToLeave.push(key);
}
}
@@ -163,4 +163,22 @@ describe('ReactCSSTransitionGroup', function() {
expect(a.getDOMNode().childNodes[0].id).toBe('one');
});
it('should transition from false to one', function() {
var a = React.renderComponent(
<ReactCSSTransitionGroup transitionName="yolo">
{false}
</ReactCSSTransitionGroup>,
container
);
expect(a.getDOMNode().childNodes.length).toBe(0);
React.renderComponent(
<ReactCSSTransitionGroup transitionName="yolo">
<span key="one" id="one" />
</ReactCSSTransitionGroup>,
container
);
expect(a.getDOMNode().childNodes.length).toBe(1);
expect(a.getDOMNode().childNodes[0].id).toBe('one');
});
});