mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Merge pull request #1492 from spicyj/rtg-from-false
ReactTransitionGroup: Fix moving from falsey child
This commit is contained in:
@@ -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');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user