Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReactTransitionGroup: Fix changing to null child #1458

Merged
merged 1 commit into from
Apr 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/addons/transitions/ReactTransitionGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/addons/transitions/__tests__/ReactCSSTransitionGroup-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});

});