mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Prevent exception on Firefox due to getSelection returning null (#57)
This commit is contained in:
@@ -158,11 +158,13 @@ const setSelectionTo = (target, collapse) => {
|
||||
}
|
||||
if (range) {
|
||||
const sel = range.startContainer.ownerDocument.defaultView.getSelection()
|
||||
if (sel) {
|
||||
sel.removeAllRanges()
|
||||
if (collapse === -1) range.collapse(true)
|
||||
else if (collapse === 1) range.collapse()
|
||||
sel.addRange(range)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getDirection = doc => {
|
||||
|
||||
Reference in New Issue
Block a user