Fixing text to land algorithm - handling case when no child text element exist better
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 15 Jul 2013 21:17:33 +0000 (23:17 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Mon, 15 Jul 2013 21:17:33 +0000 (23:17 +0200)
modules/documentCanvas/canvas/canvas.js

index 50ca6c0..a3d24a0 100644 (file)
@@ -217,12 +217,13 @@ $.extend(Canvas.prototype, {
                 this._moveCaretToTextElement(textElementToLand, params.caretTo); // as method on element?
             if(!(textElementToLand.sameNode(currentTextElement)))
                 this.publisher('currentTextElementSet', element);
+        } else {
+            document.getSelection().removeAllRanges();
         }
 
         if(!(currentNodeElement && currentNodeElement.sameNode(nodeElementToLand))) {
             _markAsCurrent(nodeElementToLand);
-            if(!textElementToLand)
-                document.getSelection().removeAllRanges();
+
             this.publisher('currentNodeElementSet', nodeElementToLand);
         }
     },