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

Commit dca7608

Browse files
author
John Messerly
committed
Merge pull request #502 from Polymer/polymer_512
don't discard destination insertion points of the shadow host
2 parents cebc30c + 70e7d91 commit dca7608

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
lines changed

src/ShadowRenderer.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@
298298

299299
// http://w3c.github.io/webcomponents/spec/shadow/#distribution-algorithms
300300
distribution: function(root) {
301-
this.resetAll(root);
301+
this.resetAllSubtrees(root);
302302
this.distributionResolution(root);
303303
},
304304

@@ -308,6 +308,10 @@
308308
else
309309
resetDestinationInsertionPoints(node);
310310

311+
this.resetAllSubtrees(node);
312+
},
313+
314+
resetAllSubtrees: function(node) {
311315
for (var child = node.firstChild; child; child = child.nextSibling) {
312316
this.resetAll(child);
313317
}

test/js/reprojection.js

+31-1
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,34 @@ suite('Shadow DOM reprojection', function() {
262262
var content3 = sr3.appendChild(document.createElement('content'));
263263
assert.equal(getVisualInnerHtml(div), '<a><b><d></d></b></a>');
264264
});
265-
});
265+
266+
test('Polymer Issue 512', function () {
267+
// div
268+
// - shadow-root
269+
// -- content
270+
// - a
271+
// -- shadow-root
272+
// --- content
273+
// -- b
274+
275+
var div = document.createElement('div');
276+
var sr = div.createShadowRoot();
277+
var content = sr.appendChild(document.createElement('content'));
278+
var a = div.appendChild(document.createElement('a'));
279+
var b = a.appendChild(document.createElement('b'));
280+
b.offsetWidth;
281+
282+
var srA = a.createShadowRoot();
283+
var contentA = srA.appendChild(document.createElement('content'));
284+
// Ensure we don't improperly reset the insertion point for the shadow host
285+
// node "a" when we re-render it. The fact that "a" was inserted somewhere
286+
// else is not a concern when we are only re-rendering its shadow root.
287+
b.offsetWidth;
288+
289+
assertArrayEqual(content.getDistributedNodes(), [a]);
290+
assertArrayEqual(contentA.getDistributedNodes(), [b]);
291+
292+
assertArrayEqual(a.getDestinationInsertionPoints(), [content]);
293+
assertArrayEqual(b.getDestinationInsertionPoints(), [contentA]);
294+
});
295+
});

0 commit comments

Comments
 (0)