smartxml: optimize undo for setText transformation
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 17 Dec 2013 10:51:08 +0000 (11:51 +0100)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 17 Dec 2013 10:51:08 +0000 (11:51 +0100)
src/smartxml/core.js

index 867353d..4d3c2c1 100644 (file)
@@ -188,9 +188,15 @@ var elementNodeTransformations = {
 };
 
 var textNodeTransformations = {
 };
 
 var textNodeTransformations = {
-    setText: function(text) {
-        this.nativeNode.data = text;
-        this.triggerTextChangeEvent();
+    setText: {
+        impl: function(t, text) {
+            t.oldText = this.getText();
+            this.nativeNode.data = text;
+            this.triggerTextChangeEvent();
+        },
+        undo: function(t) {
+            this.setText(t.oldText);
+        }
     },
 
     appendText: function(text) {
     },
 
     appendText: function(text) {