+
+ it('keeps parent-describing nodes in place', function() {
+ var section = elementNodeFromXML('<section>Alice<x></x><div>a cat</div></section>'),
+ aliceText = section.contents()[0],
+ x = section.contents()[1],
+ lastDiv = section.contents()[2];
+
+ section.document.registerExtension({documentNode: {methods: {
+ object: {
+ describesParent: function() {
+ return this.nodeType === Node.ELEMENT_NODE && this.getTagName() === 'x';
+ }
+ }
+ }}});
+
+ section.document.wrapNodes({
+ node1: aliceText,
+ node2: lastDiv,
+ _with: {tagName: 'header'}
+ });
+
+ expect(x.parent().sameNode(section)).to.be.true;
+ expect(aliceText.parent().getTagName()).to.equal('header');
+ expect(lastDiv.parent().getTagName()).to.equal('header');
+ });