Skip to content

Commit

Permalink
report: remove use of innerHTML to empty elements (#15911)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish authored and adamraine committed Apr 5, 2024
1 parent cc121c1 commit 6dc8cee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
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

0 comments on commit 6dc8cee

Please sign in to comment.