From 50ba9cea2b6034b33c283da88a6d0022aca6dfed Mon Sep 17 00:00:00 2001 From: Steven Orvell Date: Thu, 14 Feb 2019 14:19:51 -0800 Subject: [PATCH] Use `ShadyDOM.upgrade` This is a more optimized way to create and populate a `shadowRoot`. --- lib/mixins/element-mixin.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/mixins/element-mixin.js b/lib/mixins/element-mixin.js index c931fb7fc0..a8dbc8ab14 100644 --- a/lib/mixins/element-mixin.js +++ b/lib/mixins/element-mixin.js @@ -672,9 +672,13 @@ export const ElementMixin = dedupingMixin(base => { if (n.attachShadow) { if (dom) { if (!n.shadowRoot) { - n.attachShadow({mode: 'open'}); + if (window.ShadyDOM) { + ShadyDOM.upgrade(dom, this, {mode: 'open'}); + } else { + n.attachShadow({mode: 'open'}); + n.shadowRoot.appendChild(dom); + } } - n.shadowRoot.appendChild(dom); if (syncInitialRender && window.ShadyDOM) { ShadyDOM.flushInitial(n.shadowRoot); }