Fixing canvas.nodeInsideList
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 27 Jun 2013 11:35:16 +0000 (13:35 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 27 Jun 2013 11:35:16 +0000 (13:35 +0200)
modules/documentCanvas/canvas.js
modules/documentCanvas/tests/canvas.test.js

index 9ae3a53..d0629d3 100644 (file)
@@ -193,7 +193,7 @@ Canvas.prototype.nodeInsideList = function(options) {
         if(options.node.getClass() === 'list-items' || options.node.getClass() === 'item')\r
             return true;\r
         var pointerElement = $(this.content.find('#' + options.node.getId()));\r
         if(options.node.getClass() === 'list-items' || options.node.getClass() === 'item')\r
             return true;\r
         var pointerElement = $(this.content.find('#' + options.node.getId()));\r
-        return pointerElement.parents('list-items, item').length > 0;\r
+        return pointerElement.parents('[wlxml-class=list-items], [wlxml-class=item]').length > 0;\r
     }\r
     return false;\r
 };\r
     }\r
     return false;\r
 };\r
index afe777a..fc842e5 100644 (file)
@@ -179,12 +179,12 @@ define([
             var c = canvas.create(utils.cleanUp('\\r
                 <div wlxml-tag="section">\\r
                     <div wlxml-tag="div" wlxml-class="list-items-enum">\\r
             var c = canvas.create(utils.cleanUp('\\r
                 <div wlxml-tag="section">\\r
                     <div wlxml-tag="div" wlxml-class="list-items-enum">\\r
-                        <div wlxml-tag="div" wlxml-class="item">alice</div>\\r
+                        <div wlxml-tag="div" wlxml-class="item">alice <span wlxml-tag="span"></span</div>\\r
                         <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
                     </div>\\r
                 </div>'));\r
                         <div wlxml-tag="div" wlxml-class="item">cat</div>\\r
                     </div>\\r
                 </div>'));\r
-            var item = c.findNodes({klass: 'item'})[1];\r
-            assert.ok(c.nodeInsideList({node: item}));\r
+            assert.ok(c.nodeInsideList({node: c.findNodes({klass: 'item'})[1]}), 'item is inside a list');\r
+            assert.ok(c.nodeInsideList({node: c.findNodes({tag: 'span'})[0]}), 'things nested in item are inside a list');\r
         });\r
     });\r
 });
\ No newline at end of file
         });\r
     });\r
 });
\ No newline at end of file