}\r
\r
Canvas.prototype.setXML = function(xml) {\r
- this.xml = xml;\r
- this.content.html(transformations.fromXML.getHTMLTree(xml)); \r
+ this.xml = $.trim(xml);\r
+ this.content.html(transformations.fromXML.getHTMLTree(this.xml)); \r
}\r
\r
Canvas.prototype.toXML = function() {\r
node.remove();\r
list.append(node);\r
});\r
+}\r
+\r
+Canvas.prototype.removeList = function(options) {\r
+ var pointerElement = $(this.content.find('#' + options.pointer.id));\r
+ var listElement = options.pointer.klass === 'list-items' ? pointerElement : \r
+ pointerElement.parent('[wlxml-class="list-items"][wlxml-tag]');\r
\r
- \r
+ listElement.find('[wlxml-class=item]').each(function() {\r
+ $(this).attr('wlxml-class', '');\r
+ });;\r
+ listElement.children().unwrap();\r
\r
}\r
\r
</section>');\r
\r
});\r
+ \r
+ test('remove list', function() {\r
+ var xml = '\\r
+ <section>\\r
+ <div class="list.items">\\r
+ <div class="item">Alice</div>\\r
+ <div class="item">has</div>\\r
+ <div class="item">a cat</div>\\r
+ </div>\\r
+ <div>some text</div>\\r
+ </section>';\r
+ var c = new canvas.Canvas(xml);\r
+ var item = c.getNode({klass: 'item'})[1];\r
+ c.removeList({pointer: item});\r
+ assert.xmlEqual(c.toXML(), '\\r
+ <section>\\r
+ <div>Alice</div>\\r
+ <div>has</div>\\r
+ <div>a cat</div>\\r
+ <div>some text</div>\\r
+ </section>');\r
+ });\r
});\r
\r
});
\ No newline at end of file
var wlxmlName = split.splice(1).join('-');\r
var value = wlxmlName === 'class' ? attr.value.replace(/-/g, '.') : attr.value;\r
console.log(name + ': ' + value);\r
- toret.attr(wlxmlName, value);\r
+ if(value.length && value.length > 0)\r
+ toret.attr(wlxmlName, value);\r
}\r
\r
toret.append(div.contents());\r