From 5501cccc67651f222e4328e3051e9aa9f9f9c5f3 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Fri, 10 May 2019 14:12:08 -0700 Subject: [PATCH] Fix custom panel paths (#3188) --- src/common/feature-detect/support-web-components.ts | 2 ++ src/entrypoints/custom-panel.ts | 10 +++------- 2 files changed, 5 insertions(+), 7 deletions(-) create mode 100644 src/common/feature-detect/support-web-components.ts 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`) ); }