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 3 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
9 changes: 4 additions & 5 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,6 +215,7 @@ export class LighthouseReportViewer {
return;
}

const dom = new DOM(document, rootEl);
const renderer = new ReportRenderer(dom);

renderer.renderReport(json, rootEl, {
Expand All @@ -224,7 +224,6 @@ export class LighthouseReportViewer {

const features = new ViewerUIFeatures(dom, {
saveGist: saveGistCallback,
/** @param {LH.Result} newLhr */
refresh: newLhr => {
this._replaceReportHtml(newLhr);
},
Expand Down Expand Up @@ -258,11 +257,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', 'lh-root lh-vars');
connorjclark marked this conversation as resolved.
Show resolved Hide resolved
container.append(rootEl);

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