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

Commit

Permalink
Make sure we do not remove the shadow dom of nested hosts.
Browse files Browse the repository at this point in the history
  • Loading branch information
arv committed Sep 11, 2013
1 parent be345ce commit 00ef46e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ShadowRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@
* the real DOM tree and make minimal changes as needed.
*/
function RenderNode(node) {
this.skip = false;
this.node = node;
this.childNodes = [];
}
Expand All @@ -278,6 +279,9 @@
},

sync: function(opt_added) {
if (this.skip)
return;

var nodeWrapper = this.node;
// plain array of RenderNodes
var newChildren = this.childNodes;
Expand Down Expand Up @@ -390,6 +394,7 @@

if (isShadowHost(node)) {
var renderer = getRendererForHost(node);
renderNode.skip = !renderer.dirty;
renderer.render(renderNode);
} else {
// We associate the parent of a content/shadow with the renderer
Expand Down
14 changes: 14 additions & 0 deletions test/js/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -451,4 +451,18 @@ suite('Shadow DOM', function() {
assert.equal(a.childNodes.length, 2);
});

test('nested shadow hosts (issue 245)', function() {
var outer = document.createElement('outer');
var inner = outer.appendChild(document.createElement('inner'));

// Inner first. Order matters.
var innerShadowRoot = inner.createShadowRoot();
innerShadowRoot.textContent = 'inner';

var outerShadowRoot = outer.createShadowRoot();
outerShadowRoot.innerHTML = '<content></content>outer';

assert.equal(getVisualInnerHtml(outer), '<inner>inner</inner>outer');
});

});

0 comments on commit 00ef46e

Please sign in to comment.