Merge pull request #1492 from spicyj/rtg-from-false

ReactTransitionGroup: Fix moving from falsey child
This commit is contained in:
Paul O’Shannessy
2014-05-08 09:46:49 -07:00
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');
});
});