mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
@@ -79,6 +79,15 @@ var ReactTransitionGroup = React.createClass({
|
||||
enter: this.props.transitionEnter,
|
||||
onDoneLeaving: this._handleDoneLeaving.bind(this, key)
|
||||
}, childMapping[key]);
|
||||
} else {
|
||||
// If there's no leave transition and the child has been removed from
|
||||
// the source children list, we want to remove it immediately from the
|
||||
// _transitionGroupCurrentKeys cache because _handleDoneLeaving won't
|
||||
// be called. In normal cases, this prevents a small memory leak; in
|
||||
// the case of switching transitionLeave from false to true, it
|
||||
// prevents a confusing bug where ReactTransitionableChild.render()
|
||||
// returns nothing, throwing an error.
|
||||
delete currentKeys[key];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -83,6 +83,41 @@ describe('ReactTransitionGroup', function() {
|
||||
expect(a.getDOMNode().childNodes[1].id).toBe('one');
|
||||
});
|
||||
|
||||
it('should switch transitionLeave from false to true', function() {
|
||||
var a = React.renderComponent(
|
||||
<ReactTransitionGroup
|
||||
transitionName="yolo"
|
||||
transitionEnter={false}
|
||||
transitionLeave={false}>
|
||||
<span key="one" id="one" />
|
||||
</ReactTransitionGroup>,
|
||||
container
|
||||
);
|
||||
expect(a.getDOMNode().childNodes.length).toBe(1);
|
||||
React.renderComponent(
|
||||
<ReactTransitionGroup
|
||||
transitionName="yolo"
|
||||
transitionEnter={false}
|
||||
transitionLeave={false}>
|
||||
<span key="two" id="two" />
|
||||
</ReactTransitionGroup>,
|
||||
container
|
||||
);
|
||||
expect(a.getDOMNode().childNodes.length).toBe(1);
|
||||
React.renderComponent(
|
||||
<ReactTransitionGroup
|
||||
transitionName="yolo"
|
||||
transitionEnter={false}
|
||||
transitionLeave={true}>
|
||||
<span key="three" id="three" />
|
||||
</ReactTransitionGroup>,
|
||||
container
|
||||
);
|
||||
expect(a.getDOMNode().childNodes.length).toBe(2);
|
||||
expect(a.getDOMNode().childNodes[0].id).toBe('three');
|
||||
expect(a.getDOMNode().childNodes[1].id).toBe('two');
|
||||
});
|
||||
|
||||
describe('with an undefined child', function () {
|
||||
it('should fail silently', function () {
|
||||
React.renderComponent(
|
||||
|
||||
Reference in New Issue
Block a user