From 2cfff991ac2de403cf96c86e5a20a05956587a3f Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Mon, 25 Jun 2018 15:59:17 -0400 Subject: [PATCH] Do not use async await in custom panels (#1336) * Do not use async await in custom panels * Lint --- src/util/custom-panel/load-custom-panel.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/util/custom-panel/load-custom-panel.js b/src/util/custom-panel/load-custom-panel.js index 8c4a0fdb9f..64d938c4f5 100644 --- a/src/util/custom-panel/load-custom-panel.js +++ b/src/util/custom-panel/load-custom-panel.js @@ -3,7 +3,7 @@ import { loadJS } from '../../common/dom/load_resource.js'; // Make sure we only import every JS-based panel once (HTML import has this built-in) const JS_CACHE = {}; -export default async function loadCustomPanel(panelConfig) { +export default function loadCustomPanel(panelConfig) { if (panelConfig.html_url) { const toLoad = [ import(/* webpackChunkName: "import-href-polyfill" */ '../../resources/html-import/import-href.js'), @@ -13,14 +13,13 @@ export default async function loadCustomPanel(panelConfig) { toLoad.push(import(/* webpackChunkName: "legacy-support" */ '../legacy-support.js')); } - const [{ importHrefPromise }] = await Promise.all(toLoad); - await importHrefPromise(panelConfig.html_url); + return Promise.all(toLoad).then(([{ importHrefPromise }]) => + importHrefPromise(panelConfig.html_url)); } else if (panelConfig.js_url) { if (!(panelConfig.js_url in JS_CACHE)) { JS_CACHE[panelConfig.js_url] = loadJS(panelConfig.js_url); } - await JS_CACHE[panelConfig.js_url]; - } else { - throw new Error('No valid url found in panel config.'); + return JS_CACHE[panelConfig.js_url]; } + return Promise.reject('No valid url found in panel config.'); }