From: Alexander Ebert Date: Fri, 9 Feb 2018 12:57:13 +0000 (+0100) Subject: Avoid incorrect selection handling w/o a selection X-Git-Tag: 3.0.12~2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=03c386a48035bf31cac9c96e130b38ea735c622a;p=GitHub%2FWoltLab%2FWCF.git Avoid incorrect selection handling w/o a selection --- diff --git a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js index 6d50f4d6be..59e33c6a03 100644 --- a/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js +++ b/wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js @@ -70,13 +70,15 @@ $.Redactor.prototype.WoltLabCaret = function() { this.selection.saveInstant = (function() { mpSaveInstant.call(this); - this.saved.isAtNodeStart = false; - - var selection = window.getSelection(); - if (selection.rangeCount && !selection.isCollapsed) { - var range = selection.getRangeAt(0); - if (range.startContainer.nodeType === Node.TEXT_NODE && range.startOffset === 0) { - this.saved.isAtNodeStart = true; + if (this.saved) { + this.saved.isAtNodeStart = false; + + var selection = window.getSelection(); + if (selection.rangeCount && !selection.isCollapsed) { + var range = selection.getRangeAt(0); + if (range.startContainer.nodeType === Node.TEXT_NODE && range.startOffset === 0) { + this.saved.isAtNodeStart = true; + } } } }).bind(this);