Skip to content

Commit 0c9c9c9

Browse files
committed
prevent null error on selection change
1 parent 8bc59cd commit 0c9c9c9

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@ yarn-error.log*
2222

2323
# Misc
2424
.ghnpmpkgtoken
25+
package-lock.json

src/UserInput.vue

+4-3
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,10 @@ export default {
181181
document.addEventListener('selectionchange', () => {
182182
var selection = document.getSelection()
183183
if (
184-
selection.anchorNode &&
185-
selection.anchorNode != this.$refs.userInput &&
186-
selection.anchorNode.parentNode != this.$refs.userInput
184+
!selection ||
185+
!selection.anchorNode ||
186+
(selection.anchorNode != this.$refs.userInput &&
187+
selection.anchorNode.parentNode != this.$refs.userInput)
187188
) {
188189
return
189190
}

0 commit comments

Comments
 (0)