From 0af4b17c20c384c3985e78d949c08006b88977d4 Mon Sep 17 00:00:00 2001 From: mofux Date: Fri, 14 Jul 2017 15:56:14 +0200 Subject: [PATCH] Guard public selection api --- src/xterm.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/xterm.js b/src/xterm.js index d625a3c..6be1367 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -1437,7 +1437,7 @@ Terminal.prototype.deregisterLinkMatcher = function(matcherId) { * Gets whether the terminal has an active selection. */ Terminal.prototype.hasSelection = function() { - return this.selectionManager.hasSelection; + return !!(this.selectionManager && this.selectionManager.hasSelection); }; /** @@ -1445,21 +1445,25 @@ Terminal.prototype.hasSelection = function() { * behavior outside of xterm.js. */ Terminal.prototype.getSelection = function() { - return this.selectionManager.selectionText; + return this.selectionManager ? this.selectionManager.selectionText : ''; }; /** * Clears the current terminal selection. */ Terminal.prototype.clearSelection = function() { - this.selectionManager.clearSelection(); + if (this.selectionManager) { + this.selectionManager.clearSelection(); + } }; /** * Selects all text within the terminal. */ Terminal.prototype.selectAll = function() { - this.selectionManager.selectAll(); + if (this.selectionManager) { + this.selectionManager.selectAll(); + } }; /**