Fix custom panel paths (#3188)

This commit is contained in:
Paulus Schoutsen 2019-05-10 14:12:08 -07:00 committed by GitHub
parent 9340d9068e
commit 5501cccc67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View File

@ -0,0 +1,2 @@
export const webComponentsSupported =
"customElements" in window && "content" in document.createElement("template");

View File

@ -5,6 +5,7 @@ import { setCustomPanelProperties } from "../util/custom-panel/set-custom-panel-
import { fireEvent } from "../common/dom/fire_event"; import { fireEvent } from "../common/dom/fire_event";
import { PolymerElement } from "@polymer/polymer"; import { PolymerElement } from "@polymer/polymer";
import { CustomPanelInfo } from "../data/panel_custom"; import { CustomPanelInfo } from "../data/panel_custom";
import { webComponentsSupported } from "../common/feature-detect/support-web-components";
declare global { declare global {
interface Window { 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<unknown> | undefined; let es5Loaded: Promise<unknown> | undefined;
window.loadES5Adapter = () => { window.loadES5Adapter = () => {
if (!es5Loaded) { if (!es5Loaded) {
es5Loaded = Promise.all([ es5Loaded = Promise.all([
loadJS( loadJS(
`${__STATIC_PATH__}/polyfills/custom-elements-es5-adapter.js` `${__STATIC_PATH__}polyfills/custom-elements-es5-adapter.js`
).catch(), ).catch(),
import(/* webpackChunkName: "compat" */ "./compatibility"), import(/* webpackChunkName: "compat" */ "./compatibility"),
]); ]);
@ -50,7 +46,7 @@ function initialize(panel: CustomPanelInfo, properties: {}) {
if (!webComponentsSupported) { if (!webComponentsSupported) {
start = start.then(() => start = start.then(() =>
loadJS(`${__STATIC_PATH__}/polyfills/webcomponents-bundle.js`) loadJS(`${__STATIC_PATH__}polyfills/webcomponents-bundle.js`)
); );
} }