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 use of innerHTML to empty elements #15911

Merged
merged 1 commit into from
Apr 2, 2024
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
12 changes: 6 additions & 6 deletions treemap/app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class TreemapViewer {

createBundleSelector() {
const bundleSelectorEl = TreemapUtil.find('select.bundle-selector');
bundleSelectorEl.innerHTML = ''; // Clear just in case document was saved with Ctrl+S.
bundleSelectorEl.textContent = ''; // Clear just in case document was saved with Ctrl+S.

/** @type {LH.Treemap.Selector[]} */
const selectors = [];
Expand Down Expand Up @@ -428,7 +428,7 @@ class TreemapViewer {
spacing: 10,
caption: node => this.makeCaption(node),
});
this.el.innerHTML = '';
this.el.textContent = '';
this.treemap.render(this.el);
TreemapUtil.find('.webtreemap-node').classList.add('webtreemap-node--root');

Expand All @@ -448,7 +448,7 @@ class TreemapViewer {

createTable() {
const tableEl = TreemapUtil.find('.lh-table');
tableEl.innerHTML = '';
tableEl.textContent = '';

/** @type {Array<{node: NodeWithElement, name: string, bundleNode?: LH.Treemap.Node, resourceBytes: number, unusedBytes?: number}>} */
const data = [];
Expand Down Expand Up @@ -692,7 +692,7 @@ function renderViewModeButtons(viewModes) {
}

const viewModesEl = TreemapUtil.find('.lh-modes');
viewModesEl.innerHTML = '';
viewModesEl.textContent = '';
viewModes.forEach(render);
}

Expand Down Expand Up @@ -792,8 +792,8 @@ class LighthouseTreemap {
}

if (treemapViewer) {
TreemapUtil.find('.lh-treemap').innerHTML = '';
TreemapUtil.find('.lh-table').innerHTML = '';
TreemapUtil.find('.lh-treemap').textContent = '';
TreemapUtil.find('.lh-table').textContent = '';
treemapViewer.abortController.abort();
}
treemapViewer = new TreemapViewer(options, TreemapUtil.find('div.lh-treemap'));
Expand Down
4 changes: 2 additions & 2 deletions viewer/app/src/lighthouse-report-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ export class LighthouseReportViewer {
const container = find('main', document);

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

Expand All @@ -300,7 +300,7 @@ export class LighthouseReportViewer {
}
} catch (e) {
logger.error(`Error rendering report: ${e.stack}`);
container.innerHTML = '';
container.textContent = '';
throw e;
} finally {
this._reportIsFromGist = this._reportIsFromPSI = this._reportIsFromJSON = false;
Expand Down
Loading