setTag: function(tagName) {
var node = this.document.createElementNode({tagName: tagName}),
- oldTagName = this.getTagName();
+ oldTagName = this.getTagName(),
+ myContents = this._$.contents();
this.getAttrs().forEach(function(attribute) {
node.setAttr(attribute.name, attribute.value, true);
}
this._$.replaceWith(node._$);
this._setNativeNode(node._$[0]);
+ this._$.append(myContents);
this.triggerChangeEvent('nodeTagChange', {oldTagName: oldTagName, newTagName: this.getTagName()});
},
doc.root.setTag('span');
expect(doc.root.getTagName()).to.equal('span');
});
+
+ it('keeps contents', function() {
+ var node = elementNodeFromXML('<div><div></div></div>');
+ node.setTag('header');
+ expect(node.contents()).to.have.length(1);
+ });
});