]> git.proxmox.com Git - mirror_xterm.js.git/commitdiff
Make fit plugin guard against non-existent parent element.
authorLucian Buzzo <lucian.buzzo@gmail.com>
Mon, 13 Feb 2017 21:01:28 +0000 (21:01 +0000)
committerLucian Buzzo <lucian.buzzo@gmail.com>
Mon, 13 Feb 2017 21:01:28 +0000 (21:01 +0000)
src/addons/fit/fit.js

index cacd9202c3394e5a3d12176b4b14dae83f0ee053..11fc6eb79fbc6ec7853273596c64dae73e93188a 100644 (file)
@@ -32,6 +32,9 @@
   var exports = {};
 
   exports.proposeGeometry = function (term) {
+    if (!term.element.parentElement) {
+      return null;
+    }
     var parentElementStyle = window.getComputedStyle(term.element.parentElement),
         parentElementHeight = parseInt(parentElementStyle.getPropertyValue('height')),
         parentElementWidth = Math.max(0, parseInt(parentElementStyle.getPropertyValue('width')) - 17),
@@ -66,7 +69,9 @@
   exports.fit = function (term) {
     var geometry = exports.proposeGeometry(term);
 
-    term.resize(geometry.cols, geometry.rows);
+    if (geometry) {
+      term.resize(geometry.cols, geometry.rows);
+    }
   };
 
   Xterm.prototype.proposeGeometry = function () {