From 503822deb087a6e109292737cb906d8987f8102e Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Thu, 15 Jun 2017 14:32:00 +0100 Subject: [PATCH] avoid possible exception if selection is undefined defensive programming only --- .../web/public/coffee/ide/pdfng/directives/pdfViewer.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee b/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee index ae9421cef3..fe7ea3d427 100644 --- a/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee +++ b/services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee @@ -441,11 +441,11 @@ define [ return true _hasSelection = () -> - selection = window.getSelection() + selection = window.getSelection?() # check the selection type in preference to using # selection.toString() as the latter is "" when the # selection is hidden (e.g. while viewing logs) - return _isSelectionWithinPDF(selection) and selection.type is 'Range' + return selection? and _isSelectionWithinPDF(selection) and selection.type is 'Range' _isSelectionWithinPDF = (selection) -> if selection.rangeCount == 0