From 93f2e80e61a5a4aefb50c8963eb4f1e6ad748a16 Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Mon, 3 May 2021 11:42:44 +0200 Subject: [PATCH] app-shell: Support the new scoped elements registry polyfill Register the activity properly and create a scoped element if the API is there. One all bugs are fixed upstream this should allow us to switch to lit v2 without any further changes. --- packages/app-shell/src/app-shell.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/app-shell/src/app-shell.js b/packages/app-shell/src/app-shell.js index 654ad8b2..2a8d6974 100644 --- a/packages/app-shell/src/app-shell.js +++ b/packages/app-shell/src/app-shell.js @@ -729,7 +729,19 @@ export class AppShell extends ScopedElementsMixin(AdapterLitElement) { this.track('renderActivity', activity.element); - const elm = document.createElement(activity.element); + // After it is loaded and registered globally, we get it and register it locally + customElements.whenDefined(activity.element).then(() => { + this.defineScopedElement(activity.element, customElements.get(activity.element)); + }); + + // In case of "Scoped Custom Element Registries" polyfill we create a scoped element + let elm; + if (this.shadowRoot.createElement !== undefined) { + elm = this.shadowRoot.createElement(activity.element); + } else { + elm = document.createElement(activity.element); + } + this._onActivityAdded(elm); this._lastElm = elm; return elm; -- GitLab