From bfe9d718bbf76729e897f5e252b6956a62036348 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 8 Mar 2018 13:51:05 -0800 Subject: [PATCH] closure. --- .../report/v2/renderer/category-renderer.js | 14 ++++++++------ .../report/v2/renderer/details-renderer.js | 4 ++-- .../v2/renderer/performance-category-renderer.js | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lighthouse-core/report/v2/renderer/category-renderer.js b/lighthouse-core/report/v2/renderer/category-renderer.js index c45f127cc4a1..84487efc7633 100644 --- a/lighthouse-core/report/v2/renderer/category-renderer.js +++ b/lighthouse-core/report/v2/renderer/category-renderer.js @@ -202,12 +202,14 @@ class CategoryRenderer { _renderManualAudits(manualAudits, groupDefinitions, element) { // While we could support rendering multiple groups of manual audits, it doesn't // seem desirable for UX or renderer complexity. So we'll throw. - const groupsIds = Array.from(new Set(manualAudits.map(a => a.group))); - // eslint-disable-next-line no-console - console.assert(groupsIds.length <= 1, 'More than 1 manual audit group found.'); - if (!groupsIds.length) return; - - const groupId = groupsIds[0]; + const groupsIds = new Set(manualAudits.map(a => a.group)); + /* eslint-disable no-console */ + console.assert(groupsIds.size <= 1, 'More than 1 manual audit group found.'); + console.assert(!groupsIds.has(undefined), 'Some manual audits don\'t belong to a group'); + /* eslint-enable no-console */ + if (!groupsIds.size) return; + + const groupId = /** @type {string} */ (Array.from(groupsIds)[0]); const auditGroupElem = this.renderAuditGroup(groupDefinitions[groupId], {expandable: true}); auditGroupElem.classList.add('lh-audit-group--manual'); diff --git a/lighthouse-core/report/v2/renderer/details-renderer.js b/lighthouse-core/report/v2/renderer/details-renderer.js index e26a41acbad8..bbc714102136 100644 --- a/lighthouse-core/report/v2/renderer/details-renderer.js +++ b/lighthouse-core/report/v2/renderer/details-renderer.js @@ -347,7 +347,7 @@ if (typeof module !== 'undefined' && module.exports) { * @typedef {{ * type: string, * value: (string|number|undefined), - * summary: (DetailsRenderer.DetailsSummary|undefined), + * summary: (DetailsRenderer.OpportunitySummary|undefined), * granularity: (number|undefined), * displayUnit: (string|undefined) * }} @@ -451,4 +451,4 @@ DetailsRenderer.FilmstripDetails; // eslint-disable-line no-unused-expressions * wastedBytes: (number|undefined), * }} */ -DetailsRenderer.DetailsSummary; // eslint-disable-line no-unused-expressions +DetailsRenderer.OpportunitySummary; // eslint-disable-line no-unused-expressions diff --git a/lighthouse-core/report/v2/renderer/performance-category-renderer.js b/lighthouse-core/report/v2/renderer/performance-category-renderer.js index a39116f126cc..91f8f6abcb57 100644 --- a/lighthouse-core/report/v2/renderer/performance-category-renderer.js +++ b/lighthouse-core/report/v2/renderer/performance-category-renderer.js @@ -67,7 +67,7 @@ class PerformanceCategoryRenderer extends CategoryRenderer { } const details = audit.result.details; - const summaryInfo = /** @type {!DetailsRenderer.DetailsSummary} + const summaryInfo = /** @type {!DetailsRenderer.OpportunitySummary} */ (details && details.summary); // eslint-disable-next-line no-console console.assert(summaryInfo, 'Missing `summary` for perf-hint audit');