Skip to content

Commit b5cc6ce

Browse files
committed
fixed null errors and empty input div
1 parent 60a6d94 commit b5cc6ce

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/UserInput.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ export default {
181181
document.addEventListener('selectionchange', () => {
182182
var selection = document.getSelection()
183183
if (
184+
selection.anchorNode &&
184185
selection.anchorNode != this.$refs.userInput &&
185186
selection.anchorNode.parentNode != this.$refs.userInput
186187
) {
@@ -307,7 +308,9 @@ export default {
307308
_insertEmoji(emoji) {
308309
var range = this.previousSelectionRange
309310
if (!range) {
310-
console.log('First child: ' + this.$refs.userInput.firstChild)
311+
if (!this.$refs.userInput.firstChild) {
312+
this.$refs.userInput.append(document.createTextNode(''))
313+
}
311314
range = document.createRange()
312315
range.setStart(this.$refs.userInput.firstChild, this.$refs.userInput.textContent.length)
313316
range.collapse(true)

0 commit comments

Comments
 (0)