var place = 'before';
var canvas = this;
- parent.children().forEach(function(element) {
+ parent.children().some(function(element) {
+ var _e = element;
if(element.sameNode(params.element1))
place = 'inside';
if(place === 'inside') {
element.setWlxmlClass('item');
elementsToWrap.push(element);
}
- if(element.sameNode(params.element2))
- return false;
+ if(_e.sameNode(params.element2))
+ return true;
});
var listElement = documentElement.DocumentNodeElement.create({tag: 'div', klass: 'list-items' + (params.type === 'enum' ? '-enum' : '')});
<div>cat</div>\
</section>'),
section = c.doc(),
- textAlice = section.children()[0],
- divCat = section.children()[3]
+ textHas = section.children()[1],
+ divA = section.children()[2]
- c.list.create({element1: textAlice, element2: divCat});
+ c.list.create({element1: textHas, element2: divA});
- expect(section.children().length).to.equal(1, 'section has one child element');
+ expect(section.children().length).to.equal(3, 'section has three child elements');
- var list = section.children()[0];
- expect(list.is('list')).to.equal(true, 'section\'s only child is a list');
- expect(list.children().length).to.equal(4, 'list contains four elements');
+ var child1 = section.children()[0],
+ list = section.children()[1],
+ child3 = section.children()[2];
+
+ expect(child1.getText()).to.equal('Alice');
+ expect(list.is('list')).to.equal(true, 'second child is a list');
+ expect(list.children().length).to.equal(2, 'list contains two elements');
list.children().forEach(function(child) {
expect(child.getWlxmlClass()).to.equal('item', 'list childs have wlxml class of item');
});
+ expect(child3.children()[0].getText()).to.equal('cat');
});
describe('extracting list items', function() {