lighthouse 9.0.0-dev.20211117 → 9.0.0-dev.20211121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2128,14 +2128,28 @@ class CategoryRenderer {
2128
2128
  /**
2129
2129
  * @param {LH.ReportResult.Category} category
2130
2130
  * @param {Record<string, LH.Result.ReportGroup>} groupDefinitions
2131
- * @param {{gatherMode: LH.Result.GatherMode}=} options
2131
+ * @param {{gatherMode: LH.Result.GatherMode, omitLabel?: boolean, onPageAnchorRendered?: (link: HTMLAnchorElement) => void}=} options
2132
2132
  * @return {DocumentFragment}
2133
2133
  */
2134
2134
  renderCategoryScore(category, groupDefinitions, options) {
2135
+ let categoryScore;
2135
2136
  if (options && Util.shouldDisplayAsFraction(options.gatherMode)) {
2136
- return this.renderCategoryFraction(category);
2137
+ categoryScore = this.renderCategoryFraction(category);
2138
+ } else {
2139
+ categoryScore = this.renderScoreGauge(category, groupDefinitions);
2140
+ }
2141
+
2142
+ if (options?.omitLabel) {
2143
+ const label = this.dom.find('.lh-gauge__label,.lh-fraction__label', categoryScore);
2144
+ label.remove();
2137
2145
  }
2138
- return this.renderScoreGauge(category, groupDefinitions);
2146
+
2147
+ if (options?.onPageAnchorRendered) {
2148
+ const anchor = this.dom.find('a', categoryScore);
2149
+ options.onPageAnchorRendered(anchor);
2150
+ }
2151
+
2152
+ return categoryScore;
2139
2153
  }
2140
2154
 
2141
2155
  /**
@@ -4723,6 +4737,7 @@ class ReportRenderer {
4723
4737
  e.preventDefault();
4724
4738
  destEl.scrollIntoView();
4725
4739
  });
4740
+ this._opts.onPageAnchorRendered?.(gaugeWrapperEl);
4726
4741
  }
4727
4742
 
4728
4743