Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions lighthouse-core/report/html/renderer/report-ui-features.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ class ReportUIFeatures {
});

tablesWithUrls.forEach((tableEl, index) => {
const numRows = this._getUrlItems(tableEl).length;
const thirdPartyRows = this._getThirdPartyRows(tableEl, this.json.finalUrl);
// No 3rd parties, no checkbox!
if (!thirdPartyRows.size) return;
// If all or none of the rows are 3rd party, no checkbox!
if (thirdPartyRows.size === numRows || !thirdPartyRows.size) return;

// create input box
const filterTemplate = this._dom.cloneTemplate('#tmpl-lh-3p-filter', this._document);
Expand Down Expand Up @@ -219,7 +220,7 @@ class ReportUIFeatures {
* @return {Map<number, HTMLTableRowElement>}
*/
_getThirdPartyRows(el, finalUrl) {
const urlItems = this._dom.findAll('.lh-text__url', el);
const urlItems = this._getUrlItems(el);
const finalUrlRootDomain = Util.getRootDomain(finalUrl);

/** @type {Map<number, HTMLTableRowElement>} */
Expand All @@ -240,6 +241,15 @@ class ReportUIFeatures {
return thirdPartyRows;
}

/**
* From a table, finds and returns URL items.
* @param {HTMLTableElement} tableEl
* @return {Array<HTMLElement>}
*/
_getUrlItems(tableEl) {
return this._dom.findAll('.lh-text__url', tableEl);
}

_setupStickyHeaderElements() {
this.topbarEl = this._dom.find('.lh-topbar', this._document);
this.scoreScaleEl = this._dom.find('.lh-scorescale', this._document);
Expand Down