Skip to content

Commit

Permalink
Restore termRef to avoid breaking change (#3437)
Browse files Browse the repository at this point in the history
  • Loading branch information
igorsdv authored and juancampa committed Jan 24, 2019
1 parent fa2c9d6 commit 0dc8fb9
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions lib/components/term.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0dc8fb9

Please sign in to comment.