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

clients(viewer): stop using legacy DOM api #15964

Merged
merged 4 commits into from
Apr 19, 2024
Merged
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
14 changes: 7 additions & 7 deletions viewer/app/src/lighthouse-report-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {ReportRenderer} from '../../../report/renderer/report-renderer.js';
import {TextEncoding} from '../../../report/renderer/text-encoding.js';
import {renderFlowReport} from '../../../flow-report/api';

// @ts-expect-error Legacy use of report renderer
const dom = new DOM(document);
const dom = new DOM(document, document.documentElement);
connorjclark marked this conversation as resolved.
Show resolved Hide resolved

/* global logger ReportGenerator */

Expand Down Expand Up @@ -216,15 +215,16 @@ export class LighthouseReportViewer {
return;
}

const renderer = new ReportRenderer(dom);
rootEl.classList.add('lh-root', 'lh-vars');
const reportDom = new DOM(document, rootEl);
const renderer = new ReportRenderer(reportDom);

renderer.renderReport(json, rootEl, {
occupyEntireViewport: true,
});

const features = new ViewerUIFeatures(dom, {
const features = new ViewerUIFeatures(reportDom, {
saveGist: saveGistCallback,
/** @param {LH.Result} newLhr */
refresh: newLhr => {
this._replaceReportHtml(newLhr);
},
Expand Down Expand Up @@ -258,11 +258,11 @@ export class LighthouseReportViewer {
// TODO: Really, `json` should really have type `unknown` and
// we can have _validateReportJson verify that it's an LH.Result
_replaceReportHtml(json) {
const container = dom.find('main', document);
const container = dom.find('main');

// Reset container content.
container.textContent = '';
const rootEl = document.createElement('div');
const rootEl = dom.createElement('div');
container.append(rootEl);

// Only give gist-saving callback if current report isn't from a gist.
Expand Down
Loading