Avoid incorrect selection handling w/o a selection
authorAlexander Ebert <ebert@woltlab.com>
Fri, 9 Feb 2018 12:57:13 +0000 (13:57 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 9 Feb 2018 16:01:55 +0000 (17:01 +0100)
wcfsetup/install/files/js/3rdParty/redactor2/plugins/WoltLabCaret.js

index 6d50f4d6be55f0c904cc64b6e17db0fb31af289a..59e33c6a039dd2e095929f3c2123bc71fbd813fd 100644 (file)
@@ -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);