Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Fix outerHTML setter so that mutation observers are notified
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed Nov 25, 2013
1 parent 6401f84 commit c632455
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/wrappers/HTMLElement.js
Expand Up @@ -137,11 +137,11 @@
return getOuterHTML(this);
},
set outerHTML(value) {
// TODO(arv): Mutation observer
var p = this.parentNode;
if (p) {
p.invalidateShadowRenderer();
this.impl.outerHTML = value;
var df = frag(p, value);
p.replaceChild(df, this);
}
},

Expand Down
32 changes: 32 additions & 0 deletions test/js/MutationObserver/childList.js
Expand Up @@ -758,6 +758,38 @@ suite('MutationObserver', function() {
});
});

test('outerHTML', function() {
var a = document.createElement('a');
a.innerHTML = '<b></b><c></c><d></d>';
var b = a.firstChild;
var c = b.nextSibling;
var d = a.lastChild;

var sr = a.createShadowRoot();
a.offsetHeight;

var observer = new MutationObserver(function() {});
observer.observe(a, {
childList: true
});

c.outerHTML = '<e></e><f></f>';
assert.equal(a.innerHTML, '<b></b><e></e><f></f><d></d>');
var e = b.nextSibling;
var f = e.nextSibling;

var records = observer.takeRecords();
assert.equal(records.length, 1);
expectMutationRecord(records[0], {
type: 'childList',
target: a,
addedNodes: [e, f],
removedNodes: [c],
previousSibling: b,
nextSibling: d
});
});

});

});

0 comments on commit c632455

Please sign in to comment.