diff --git a/lib/components/term.js b/lib/components/term.js index 19692f4f..3cd5cdf4 100644 --- a/lib/components/term.js +++ b/lib/components/term.js @@ -100,6 +100,7 @@ export default class Term extends React.PureComponent { constructor(props) { super(props); props.ref_(props.uid, this); + this.termRef = null; this.termWrapperRef = null; this.termRect = null; this.onWindowPaste = this.onWindowPaste.bind(this); @@ -117,14 +118,14 @@ export default class Term extends React.PureComponent { // The parent element for the terminal is attached and removed manually so // that we can preserve it across mounts and unmounts of the component - let parent = props.term ? props.term._core._parent : document.createElement('div'); - parent.className = 'term_fit term_term'; + this.termRef = props.term ? props.term._core._parent : document.createElement('div'); + this.termRef.className = 'term_fit term_term'; - this.termWrapperRef.appendChild(parent); + this.termWrapperRef.appendChild(this.termRef); if (!props.term) { this.term.attachCustomKeyEventHandler(this.keyboardHandler); - this.term.open(parent); + this.term.open(this.termRef); this.term.webLinksInit(); this.term.winptyCompatInit(); } @@ -320,7 +321,7 @@ export default class Term extends React.PureComponent { componentWillUnmount() { terms[this.props.uid] = null; - this.termWrapperRef.removeChild(this.term._core._parent); + this.termWrapperRef.removeChild(this.termRef); this.props.ref_(this.props.uid, null); // to clean up the terminal, we remove the listeners