Skip to content

Commit

Permalink
report: remove href from category score gauge (#13180)
Browse files Browse the repository at this point in the history
  • Loading branch information
connorjclark authored Oct 6, 2021
1 parent c219a9c commit 8b3b298
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions flow-report/src/wrappers/report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import {useReportRenderer} from './report-renderer';
export function convertChildAnchors(element: HTMLElement, index: number) {
const links = element.querySelectorAll('a') as NodeListOf<HTMLAnchorElement>;
for (const link of links) {
if (!link.href) continue;

// Check if the link destination is in the report.
const currentUrl = new URL(location.href);
currentUrl.hash = '';
Expand Down
4 changes: 2 additions & 2 deletions report/assets/templates.html
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@

<!-- Lighthouse score gauge -->
<template id="gauge">
<a href="#" class="lh-gauge__wrapper">
<a class="lh-gauge__wrapper">
<!-- Wrapper exists for the ::before plugin icon. Cannot create pseudo-elements on svgs. -->
<div class="lh-gauge__svg-wrapper">
<svg viewBox="0 0 120 120" class="lh-gauge">
Expand All @@ -565,7 +565,7 @@

<!-- Lighthouse category fraction -->
<template id="fraction">
<a href="#" class="lh-fraction__wrapper">
<a class="lh-fraction__wrapper">
<div class="lh-fraction__content-wrapper">
<div class="lh-fraction__content">
<div class="lh-fraction__background"></div>
Expand Down
1 change: 0 additions & 1 deletion report/renderer/category-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,6 @@ export class CategoryRenderer {
renderScoreGauge(category, groupDefinitions) { // eslint-disable-line no-unused-vars
const tmpl = this.dom.createComponent('gauge');
const wrapper = this.dom.find('a.lh-gauge__wrapper', tmpl);
this.dom.safelySetHref(wrapper, `#${category.id}`);

if (Util.isPluginCategory(category.id)) {
wrapper.classList.add('lh-gauge__wrapper--plugin');
Expand Down
2 changes: 0 additions & 2 deletions report/renderer/components.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions report/renderer/report-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,12 @@ export class ReportRenderer {
{gatherMode: report.gatherMode}
);

// For normal score gauges (not the fraction gauge), set the gauge href
// to link to the category.
const gaugeWrapperEl = /** @type {HTMLAnchorElement} */ (
categoryGauge.querySelector('a.lh-gauge__wrapper'));
if (gaugeWrapperEl) this._dom.safelySetHref(gaugeWrapperEl, `#${category.id}`);

if (Util.isPluginCategory(category.id)) {
pluginGauges.push(categoryGauge);
} else if (renderer.renderCategoryScore === categoryRenderer.renderCategoryScore) {
Expand Down

0 comments on commit 8b3b298

Please sign in to comment.