From e6903821a722742a7c9f8b71704852202751e5f5 Mon Sep 17 00:00:00 2001 From: Duy Khoa Date: Mon, 19 Feb 2018 01:47:50 +0800 Subject: [PATCH] Simplify condition checking in stylesFromModule function --- lib/utils/style-gather.html | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/utils/style-gather.html b/lib/utils/style-gather.html index a2bb6feda1..5c4fa8ceb6 100644 --- a/lib/utils/style-gather.html +++ b/lib/utils/style-gather.html @@ -80,7 +80,13 @@ */ stylesFromModule(moduleId) { const m = importModule(moduleId); - if (m && m._styles === undefined) { + + if (!m) { + console.warn('Could not find style data in module named', moduleId); + return []; + } + + if (m._styles === undefined) { const styles = []; // module imports: styles.push(...this._stylesFromModuleImports(m)); @@ -90,12 +96,11 @@ styles.push(...this.stylesFromTemplate(template, /** @type {templateWithAssetPath} */(m).assetpath)); } + m._styles = styles; } - if (!m) { - console.warn('Could not find style data in module named', moduleId); - } - return m ? m._styles : []; + + return m._styles; }, /**