diff --git a/lighthouse-treemap/app/src/main.js b/lighthouse-treemap/app/src/main.js index b986f4da29db..602c92ba1a90 100644 --- a/lighthouse-treemap/app/src/main.js +++ b/lighthouse-treemap/app/src/main.js @@ -15,6 +15,9 @@ const DUPLICATED_MODULES_IGNORE_THRESHOLD = 1024; const DUPLICATED_MODULES_IGNORE_ROOT_RATIO = 0.01; const logEl = document.querySelector('#lh-log'); +if (!logEl) { + throw new Error('logger element not found'); +} const logger = new Logger(logEl); /** @type {TreemapViewer} */ diff --git a/report/clients/psi.js b/report/clients/psi.js index c243f580a7af..7486401d2924 100644 --- a/report/clients/psi.js +++ b/report/clients/psi.js @@ -121,9 +121,10 @@ export function prepareLabData(LHResult, document) { const showTreemapApp = lhResult.audits['script-treemap-data'] && lhResult.audits['script-treemap-data'].details; - if (showTreemapApp) { + const buttonContainer = reportEl.querySelector('.lh-audit-group--metrics'); + if (showTreemapApp && buttonContainer) { reportUIFeatures.addButton({ - container: reportEl.querySelector('.lh-audit-group--metrics'), + container: buttonContainer, text: Util.i18n.strings.viewTreemapLabel, icon: 'treemap', onClick: () => ReportUIFeatures.openTreemap(lhResult), diff --git a/types/externs.d.ts b/types/externs.d.ts index bb195a16351a..03c78d7cc0d9 100644 --- a/types/externs.d.ts +++ b/types/externs.d.ts @@ -417,7 +417,7 @@ declare global { // Stricter querySelector/querySelectorAll using typed-query-selector. interface ParentNode { - querySelector(selector: S): QuerySelectorParse; + querySelector(selector: S): QuerySelectorParse | null; querySelectorAll(selector: S): NodeListOf>; } }