editor: Better invalid cursor handling
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 23 Apr 2014 10:49:58 +0000 (12:49 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 23 Apr 2014 10:49:58 +0000 (12:49 +0200)
src/editor/modules/documentCanvas/canvas/keyboard.js

index f879851..383ca18 100644 (file)
@@ -183,11 +183,14 @@ handlers.push({keys: [KEYS.BACKSPACE, KEYS.DELETE],
         var cursor = canvas.getCursor(),
             position = canvas.getCursor().getPosition(),
             element = position.element,
-            node = element.wlxmlNode,
+            node = element ? element.wlxmlNode : null,
             direction = 'above',
             caretTo = 'end',
             goto;
 
+        if(!element || !node) {
+            return;
+        }
             
         if(event.which === KEYS.DELETE) {
             direction = 'below';