var listElement = options.pointer.getClass() === 'list-items' ? pointerElement :
pointerElement.parents('[wlxml-class|="list-items"][wlxml-tag]');
- var nested = false;
+ var nested = false,
+ nestedLists;
if(listElement.length > 1) {
listElement = $(listElement[0]);
nested = true;
}
if(nested) {
+ // We are only moving one level up
listElement.unwrap();
} else {
+ // We are removing the whole list
+ nestedLists = listElement.find('[wlxml-class=item] > [wlxml-class|=list-items]');
+ nestedLists.unwrap();
listElement.find('[wlxml-class=item]').each(function() {
$(this).removeAttr('wlxml-class');
});
}
+
listElement.children().unwrap();
+
+ var c = this;
+ if(nestedLists) {
+ nestedLists.each(function() {
+ c.listRemove({pointer: canvasNode.create($(this))});
+ });
+ }
};
Canvas.prototype.getPrecedingNode = function(options) {
</div>'));
+ });
+
+ test('removing list containing nested list', function() {
+ var nestedList = utils.cleanUp('\
+ <div wlxml-tag="section">\
+ <div wlxml-tag="div" wlxml-class="list-items">\
+ <div wlxml-tag="div" wlxml-class="item">alice</div>\
+ <div wlxml-tag="div" wlxml-class="item">\
+ <div wlxml-tag="div" wlxml-class="list-items">\
+ <div wlxml-tag="div" wlxml-class="item">cat</div>\
+ <div wlxml-tag="div" wlxml-class="item">dog</div>\
+ </div>\
+ </div>\
+ <div wlxml-tag="div" wlxml-class="item">bee</div>\
+ </div>\
+ </div>');
+
+ var c = canvas.create(nestedList);
+ var alice_item = c.findNodes('[wlxml-class=list-items] > div')[0];
+ assert.equal(alice_item.getContent(), 'alice');
+
+ c.listRemove({pointer: alice_item});
+
+ assertDomEqual(c.getContent(), utils.cleanUp('\
+ <div wlxml-tag="section">\
+ <div wlxml-tag="div">alice</div>\
+ <div wlxml-tag="div">cat</div>\
+ <div wlxml-tag="div">dog</div>\
+ <div wlxml-tag="div">bee</div>\
+ </div>'));
+
+
});
});
});
\ No newline at end of file