Skip to content

Commit

Permalink
Added Portal remove property.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjohnsonaz committed Sep 20, 2018
1 parent 9b9c560 commit 0ac8241
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/scripts/dom/Portal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Component } from "./Component";

export interface IPortalProps {
element: HTMLElement;
remove?: boolean;
}

export default class Portal extends Component<IPortalProps> {
Expand All @@ -16,7 +17,13 @@ export default class Portal extends Component<IPortalProps> {

afterRender(node: Node, updated: boolean) {
if (!this.props.element.contains(node)) {
this.props.element.appendChild(node);
if (!this.props.remove) {
this.props.element.appendChild(node);
}
} else {
if (this.props.remove) {
this.props.element.removeChild(node);
}
}
}

Expand Down

0 comments on commit 0ac8241

Please sign in to comment.