mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
ReactTransitionGroup: Fix changing to null child
Fixes #1457. Test Plan: grunt fasttest
This commit is contained in:
@@ -61,15 +61,15 @@ var ReactTransitionGroup = React.createClass({
|
||||
var key;
|
||||
|
||||
for (key in nextChildMapping) {
|
||||
if (!prevChildMapping.hasOwnProperty(key) &&
|
||||
!this.currentlyTransitioningKeys[key]) {
|
||||
var hasPrev = prevChildMapping && prevChildMapping.hasOwnProperty(key);
|
||||
if (!hasPrev && !this.currentlyTransitioningKeys[key]) {
|
||||
this.keysToEnter.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
for (key in prevChildMapping) {
|
||||
if (!nextChildMapping.hasOwnProperty(key) &&
|
||||
!this.currentlyTransitioningKeys[key]) {
|
||||
var hasNext = nextChildMapping && nextChildMapping.hasOwnProperty(key);
|
||||
if (!hasNext && !this.currentlyTransitioningKeys[key]) {
|
||||
this.keysToLeave.push(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,4 +142,25 @@ describe('ReactCSSTransitionGroup', function() {
|
||||
container
|
||||
);
|
||||
});
|
||||
|
||||
it('should transition from one to null', function() {
|
||||
var a = React.renderComponent(
|
||||
<ReactCSSTransitionGroup transitionName="yolo">
|
||||
<span key="one" id="one" />
|
||||
</ReactCSSTransitionGroup>,
|
||||
container
|
||||
);
|
||||
expect(a.getDOMNode().childNodes.length).toBe(1);
|
||||
React.renderComponent(
|
||||
<ReactCSSTransitionGroup transitionName="yolo">
|
||||
{null}
|
||||
</ReactCSSTransitionGroup>,
|
||||
container
|
||||
);
|
||||
// (Here, we expect the original child to stick around but test that no
|
||||
// exception is thrown)
|
||||
expect(a.getDOMNode().childNodes.length).toBe(1);
|
||||
expect(a.getDOMNode().childNodes[0].id).toBe('one');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user