diff --git a/src/wrappers/HTMLElement.js b/src/wrappers/HTMLElement.js index 394dfd7..9d5de61 100644 --- a/src/wrappers/HTMLElement.js +++ b/src/wrappers/HTMLElement.js @@ -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); } }, diff --git a/test/js/MutationObserver/childList.js b/test/js/MutationObserver/childList.js index a4117e4..fe54c68 100644 --- a/test/js/MutationObserver/childList.js +++ b/test/js/MutationObserver/childList.js @@ -758,6 +758,38 @@ suite('MutationObserver', function() { }); }); + test('outerHTML', function() { + var a = document.createElement('a'); + a.innerHTML = ''; + 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 = ''; + assert.equal(a.innerHTML, ''); + 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 + }); + }); + }); });