refactoring setting text on a node
[fnpeditor.git] / src / editor / modules / documentCanvas / canvas / documentElement.js
index 99e97d0..3073e72 100644 (file)
@@ -190,7 +190,12 @@ $.extend(DocumentTextElement.prototype, {
         return this;
     },
     setText: function(text) {
-        this.dom.contents()[0].data = text;
+        if(text === '') {
+            text = utils.unicode.ZWS;
+        }
+        if(text !== this.getText()) {
+            this.dom.contents()[0].data = text;
+        }
     },
     getText: function(options) {
         options = _.extend({raw: false}, options || {});