Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

report: remove href from category score gauge #13180

Merged
merged 3 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
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">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should these even be anchors then?

<!-- 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}`);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternative: remove href from

<a href="#" class="lh-gauge__wrapper">


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