mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
avoid possible exception if selection is undefined
defensive programming only
This commit is contained in:
parent
b9804823f3
commit
503822deb0
1 changed files with 2 additions and 2 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue