Skip to content

Commit

Permalink
misc(types): fix null return on querySelector (#12848)
Browse files Browse the repository at this point in the history
  • Loading branch information
brendankenny authored Aug 3, 2021
1 parent 9827fdb commit 48031e4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 3 additions & 0 deletions lighthouse-treemap/app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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} */
Expand Down
5 changes: 3 additions & 2 deletions report/clients/psi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion types/externs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ declare global {

// Stricter querySelector/querySelectorAll using typed-query-selector.
interface ParentNode {
querySelector<S extends string>(selector: S): QuerySelectorParse<S>;
querySelector<S extends string>(selector: S): QuerySelectorParse<S> | null;
querySelectorAll<S extends string>(selector: S): NodeListOf<QuerySelectorParse<S>>;
}
}

0 comments on commit 48031e4

Please sign in to comment.