소스 검색

avoid possible exception if selection is undefined

defensive programming only
Brian Gough 9 년 전
부모
커밋
503822deb0
1개의 변경된 파일과 2개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 2
      services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee

+ 2 - 2
services/web/public/coffee/ide/pdfng/directives/pdfViewer.coffee

@@ -441,11 +441,11 @@ define [
 						return true
 						return true
 
 
 				_hasSelection = () ->
 				_hasSelection = () ->
-					selection = window.getSelection()
+					selection = window.getSelection?()
 					# check the selection type in preference to using
 					# check the selection type in preference to using
 					# selection.toString() as the latter is "" when the
 					# selection.toString() as the latter is "" when the
 					# selection is hidden (e.g. while viewing logs)
 					# 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) ->
 				_isSelectionWithinPDF = (selection) ->
 					if selection.rangeCount == 0
 					if selection.rangeCount == 0