-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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: rework the DOM of audits #5045
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,8 +27,9 @@ class CategoryRenderer { | |
* @param {!ReportRenderer.AuditJSON} audit | ||
* @return {!Element} | ||
*/ | ||
_renderAuditScore(audit) { | ||
const tmpl = this.dom.cloneTemplate('#tmpl-lh-audit-score', this.templateContext); | ||
renderAudit(audit) { | ||
const tmpl = this.dom.cloneTemplate('#tmpl-lh-audit', this.templateContext); | ||
const auditEl = this.dom.find('.lh-audit', tmpl); | ||
|
||
const scoreDisplayMode = audit.result.scoreDisplayMode; | ||
const description = audit.result.helpText; | ||
|
@@ -39,25 +40,24 @@ class CategoryRenderer { | |
} | ||
|
||
if (audit.result.debugString) { | ||
const debugStrEl = tmpl.appendChild(this.dom.createElement('div', 'lh-debug')); | ||
const debugStrEl = auditEl.appendChild(this.dom.createElement('div', 'lh-debug')); | ||
debugStrEl.textContent = audit.result.debugString; | ||
} | ||
|
||
// Append audit details to header section so the entire audit is within a <details>. | ||
const header = /** @type {!HTMLDetailsElement} */ (this.dom.find('.lh-score__header', tmpl)); | ||
const header = /** @type {!HTMLDetailsElement} */ (this.dom.find('.lh-audit__header', auditEl)); | ||
if (audit.result.details && audit.result.details.type) { | ||
header.appendChild(this.detailsRenderer.render(audit.result.details)); | ||
} | ||
|
||
const scoreEl = this.dom.find('.lh-score', tmpl); | ||
if (audit.result.informative) { | ||
scoreEl.classList.add('lh-score--informative'); | ||
auditEl.classList.add('lh-audit--informative'); | ||
} | ||
if (audit.result.manual) { | ||
scoreEl.classList.add('lh-score--manual'); | ||
auditEl.classList.add('lh-audit--manual'); | ||
} | ||
|
||
return this._populateScore(tmpl, audit.result.score, scoreDisplayMode, title, description); | ||
return this._populateScore(auditEl, audit.result.score, scoreDisplayMode, title, description); | ||
} | ||
|
||
/** | ||
|
@@ -76,9 +76,9 @@ class CategoryRenderer { | |
valueEl.classList.add(`lh-score__value--${Util.calculateRating(score)}`, | ||
`lh-score__value--${scoreDisplayMode}`); | ||
|
||
this.dom.find('.lh-score__title', element).appendChild( | ||
this.dom.find('.lh-audit__title, .lh-category-header__title', element).appendChild( | ||
this.dom.convertMarkdownCodeSnippets(title)); | ||
this.dom.find('.lh-score__description', element) | ||
this.dom.find('.lh-audit__description, .lh-category-header__description', element) | ||
.appendChild(this.dom.convertMarkdownLinkSnippets(description)); | ||
|
||
return /** @type {!Element} **/ (element); | ||
|
@@ -89,7 +89,7 @@ class CategoryRenderer { | |
* @return {!Element} | ||
*/ | ||
renderCategoryScore(category) { | ||
const tmpl = this.dom.cloneTemplate('#tmpl-lh-category-score', this.templateContext); | ||
const tmpl = this.dom.cloneTemplate('#tmpl-lh-category-header', this.templateContext); | ||
|
||
const gaugeContainerEl = this.dom.find('.lh-score__gauge', tmpl); | ||
const gaugeEl = this.renderScoreGauge(category); | ||
|
@@ -99,16 +99,6 @@ class CategoryRenderer { | |
return this._populateScore(tmpl, score, 'numeric', name, description); | ||
} | ||
|
||
/** | ||
* @param {!ReportRenderer.AuditJSON} audit | ||
* @return {!Element} | ||
*/ | ||
renderAudit(audit) { | ||
const element = this.dom.createElement('div', 'lh-audit'); | ||
element.appendChild(this._renderAuditScore(audit)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. lol |
||
return element; | ||
} | ||
|
||
/** | ||
* Renders the group container for a group of audits. Individual audit elements can be added | ||
* directly to the returned element. | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,9 @@ | |
|
||
<div id="lh-log"></div> | ||
|
||
<script>%%LIGHTHOUSE_JAVASCRIPT%%</script> | ||
<script>%%LIGHTHOUSE_JAVASCRIPT%% | ||
//# sourceURL=report-renderer-js.js | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this work with anything? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it enables a few things in devtools. like code coverage some other features that are wonky with inline |
||
</script> | ||
<script>window.__LIGHTHOUSE_JSON__ = %%LIGHTHOUSE_JSON%%;</script> | ||
<script> | ||
window.addEventListener('DOMContentLoaded', _ => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any chance you can rebase? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, jk, this is additional updates?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya additional.