Skip to content

Commit

Permalink
fix destroy. close #7
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminghe committed Apr 1, 2016
1 parent c7bb5d2 commit 88d5be8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion examples/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ const Test = React.createClass({
</div>
<div style={{ margin: 100, position: 'relative' }}>
<Trigger
getPopupContainer={null && getPopupContainer}
getPopupContainer={undefined && getPopupContainer}
popupAlign={getPopupAlign(state)}
mouseEnterDelay={0}
popupPlacement={state.placement}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-trigger",
"version": "1.3.0",
"version": "1.3.1",
"description": "base abstract trigger component for react",
"keywords": [
"react",
Expand Down
16 changes: 4 additions & 12 deletions src/Trigger.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,12 +134,7 @@ const Trigger = React.createClass({
const popupContainer = this.popupContainer;
if (popupContainer) {
ReactDOM.unmountComponentAtNode(popupContainer);
if (this.props.getPopupContainer) {
const mountNode = this.props.getPopupContainer(findDOMNode(this));
mountNode.removeChild(popupContainer);
} else {
document.body.removeChild(popupContainer);
}
popupContainer.parentNode.removeChild(popupContainer);
this.popupContainer = null;
}
this.clearDelayTimer();
Expand Down Expand Up @@ -222,12 +217,9 @@ const Trigger = React.createClass({
getPopupContainer() {
if (!this.popupContainer) {
this.popupContainer = document.createElement('div');
if (this.props.getPopupContainer) {
const mountNode = this.props.getPopupContainer(findDOMNode(this));
mountNode.appendChild(this.popupContainer);
} else {
document.body.appendChild(this.popupContainer);
}
const mountNode = this.props.getPopupContainer ?
this.props.getPopupContainer(findDOMNode(this)) : document.body;
mountNode.appendChild(this.popupContainer);
}
return this.popupContainer;
},
Expand Down

0 comments on commit 88d5be8

Please sign in to comment.