Restore termRef to avoid breaking change (#3437)

This commit is contained in:
Igor Sadikov 2019-01-24 16:02:34 -05:00 committed by onecamp
parent fa2c9d6423
commit 0dc8fb9ed4

View file

@ -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