diff --git a/src/ShadowRenderer.js b/src/ShadowRenderer.js index ee22efc..5c117e5 100644 --- a/src/ShadowRenderer.js +++ b/src/ShadowRenderer.js @@ -622,9 +622,9 @@ }; HTMLContentElement.prototype.getDistributedNodes = function() { - var renderer = this.impl.polymerShadowRenderer_; - if (renderer) - renderer.render(); + // TODO(arv): We should only rerender the dirty ancestor renderers (from + // the root and down). + renderAllPending(); return getDistributedChildNodes(this); }; diff --git a/src/wrappers/Node.js b/src/wrappers/Node.js index 55c13fc..9633c59 100644 --- a/src/wrappers/Node.js +++ b/src/wrappers/Node.js @@ -366,7 +366,11 @@ * the renderer as needed. * @private */ - nodeWasAdded_: function() {}, + nodeWasAdded_: function() { + for (var child = this.firstChild; child; child = child.nextSibling) { + child.nodeWasAdded_(); + } + }, hasChildNodes: function() { return this.firstChild === null; diff --git a/test/js/HTMLContentElement.js b/test/js/HTMLContentElement.js index 9012f85..631d3a7 100644 --- a/test/js/HTMLContentElement.js +++ b/test/js/HTMLContentElement.js @@ -55,6 +55,39 @@ suite('HTMLContentElement', function() { assertArrayEqual(content.getDistributedNodes().length, 3); }); + test('getDistributedNodes add content deep inside tree', function() { + var host = document.createElement('div'); + host.innerHTML = ' '; + var root = host.createShadowRoot(); + var b = document.createElement('b'); + var content = b.appendChild(document.createElement('content')); + content.select = '*'; + root.appendChild(b); + + assert.equal(content.getDistributedNodes().length, 3); + assertArrayEqual(content.getDistributedNodes(), host.children); + }); + + test('getDistributedNodes add content deeper inside tree', function() { + var foo = document.createElement('div'); + var fooRoot = foo.createShadowRoot(); + fooRoot.innerHTML = '