canvas api wip: remove node
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 21 Jun 2013 12:19:16 +0000 (14:19 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Fri, 21 Jun 2013 12:19:16 +0000 (14:19 +0200)
modules/documentCanvas/canvas.js
modules/documentCanvas/tests/canvas.test.js

index 20c286a..92c02c6 100644 (file)
@@ -106,6 +106,12 @@ Canvas.prototype.splitNode = function(options) {
     return newNode;\r
 }\r
 \r
     return newNode;\r
 }\r
 \r
+Canvas.prototype.removeNode = function(options) {\r
+    var toRemove = $(this.content.find('#' + options.node.id).get(0));\r
+    toRemove.remove();\r
+\r
+}\r
+\r
 Canvas.prototype.createList = function(options) {\r
     var element1 = $(this.content.find('#' + options.start.id).get(0));\r
     var element2 = $(this.content.find('#' + options.end.id).get(0));\r
 Canvas.prototype.createList = function(options) {\r
     var element1 = $(this.content.find('#' + options.start.id).get(0));\r
     var element2 = $(this.content.find('#' + options.end.id).get(0));\r
index a948787..6ba3f42 100644 (file)
@@ -93,6 +93,17 @@ define([
             );\r
         });\r
         \r
             );\r
         });\r
         \r
+        test('remove node', function() {\r
+            var c = new canvas.Canvas('<section><header class="some.class">Fancy and nice <span>header</span> 1</header></section>');\r
+            var span = c.getNode({tag: 'span'})[0];\r
+            var siblings = c.removeNode({node:span});\r
+            assert.xmlEqual(c.toXML(), '\\r
+                <section>\\r
+                    <header class="some.class">Fancy and nice  1</header>\\r
+                </section>'\r
+            );\r
+        });\r
+        \r
         test('list', function() {\r
             var c = new canvas.Canvas('<section><div>Alice</div>has<div>a cat</div></section>');\r
             var div1 = c.getNode({tag:'div'})[0];\r
         test('list', function() {\r
             var c = new canvas.Canvas('<section><div>Alice</div>has<div>a cat</div></section>');\r
             var div1 = c.getNode({tag:'div'})[0];\r