textNodeIdx: this.parent().indexOf(this),
offsetStart: Math.min(desc.start, desc.end),
offsetEnd: Math.max(desc.start, desc.end),
- _with: {tag: desc.tagName, attrs: desc.attrs}
+ _with: {tagName: desc.tagName, attrs: desc.attrs}
});
} else {
return DocumentNode.prototype.wrapWith.call(this, desc);
throw new Error('Wrapping text in non-sibling text nodes not supported.');
}
- var wrapperElement = this.createElementNode({tagName: params._with.tag, attrs: params._with.attrs});
+ var wrapperElement = this.createElementNode({tagName: params._with.tagName, attrs: params._with.attrs});
textNode1.after(wrapperElement);
textNode1.detach();
it('wraps text spanning multiple sibling TextNodes', function() {
var section = elementNodeFromXML('<section>Alice has a <span>small</span> cat</section>'),
wrapper = section.wrapText({
- _with: {tag: 'span', attrs: {'attr1': 'value1'}},
+ _with: {tagName: 'span', attrs: {'attr1': 'value1'}},
offsetStart: 6,
offsetEnd: 4,
textNodeIdx: [0,2]
var wrapper2 = section.contents()[1];
expect(wrapper2.sameNode(wrapper)).to.be.true;
+ expect(wrapper.getTagName()).to.equal('span');
var wrapperContents = wrapper.contents();
expect(wrapperContents.length).to.equal(3);