diff --git a/src/common/feature-detect/support-web-components.ts b/src/common/feature-detect/support-web-components.ts new file mode 100644 index 0000000000..607b3713ca --- /dev/null +++ b/src/common/feature-detect/support-web-components.ts @@ -0,0 +1,2 @@ +export const webComponentsSupported = + "customElements" in window && "content" in document.createElement("template"); diff --git a/src/entrypoints/custom-panel.ts b/src/entrypoints/custom-panel.ts index d6f0a33d74..9e14dc52c1 100644 --- a/src/entrypoints/custom-panel.ts +++ b/src/entrypoints/custom-panel.ts @@ -5,6 +5,7 @@ import { setCustomPanelProperties } from "../util/custom-panel/set-custom-panel- import { fireEvent } from "../common/dom/fire_event"; import { PolymerElement } from "@polymer/polymer"; import { CustomPanelInfo } from "../data/panel_custom"; +import { webComponentsSupported } from "../common/feature-detect/support-web-components"; declare global { interface Window { @@ -12,18 +13,13 @@ declare global { } } -const webComponentsSupported = - "customElements" in window && - "import" in document.createElement("link") && - "content" in document.createElement("template"); - let es5Loaded: Promise | undefined; window.loadES5Adapter = () => { if (!es5Loaded) { es5Loaded = Promise.all([ loadJS( - `${__STATIC_PATH__}/polyfills/custom-elements-es5-adapter.js` + `${__STATIC_PATH__}polyfills/custom-elements-es5-adapter.js` ).catch(), import(/* webpackChunkName: "compat" */ "./compatibility"), ]); @@ -50,7 +46,7 @@ function initialize(panel: CustomPanelInfo, properties: {}) { if (!webComponentsSupported) { start = start.then(() => - loadJS(`${__STATIC_PATH__}/polyfills/webcomponents-bundle.js`) + loadJS(`${__STATIC_PATH__}polyfills/webcomponents-bundle.js`) ); }