-
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(details-renderer): use new details types #7192
Conversation
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.
LGTM great changes!
@@ -43,52 +41,29 @@ class DetailsRenderer { | |||
} | |||
|
|||
/** | |||
* @param {DetailsJSON|OpportunityDetails} details | |||
* @param {LH.Audit.Details} details |
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.
Add a comment for what this render function does. i.e. render the top level categories of details.
@@ -100,7 +100,6 @@ declare global { | |||
id: string; | |||
/** A more detailed description that describes why the audit is important and links to Lighthouse documentation on the audit; markdown links supported. */ | |||
description: string; | |||
// TODO(bckenny): define details |
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.
🎉
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.
hot.
|
||
// Internal-only details, not for rendering. | ||
case 'screenshot': | ||
case 'diagnostic': | ||
return null; | ||
// Fallback for old LHRs, where no type meant don't render. | ||
case undefined: | ||
return null; |
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.
should we console.error or something?
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.
should we console.error or something?
I don't think it matters. This is for loading < 4.2 or whatever LHRs in the viewer. Things like diagnostics.js
and metrics.js
didn't have a type
before, now they do (type: 'diagnostic'
), so just need an explicit handling of the no-type
type.
5a5b159
to
cbb7c6c
Compare
Uses the new audit details types from #7177 in
DetailsRenderer
, finally deleting all those super old (and confusing) typedefs. Internal functionality is changed, but the generated DOM should be exactly the same.Majority of the PR is tests because
details-renderer-test.js
was really really light before this :)Main things were
opportunity
andtable
rendering (since they're both really tables). This required a_getCanonicalizedTableHeadings
method because they have differentheading
formats (which we can hopefully fix next breaking version).DetailsRenderer.render()
switch statement reflecting theaudit-details.d.ts
type structure that has a few rootdetails
types, with all the common types (text
,url
, etc) within detailsitems
. These are now rendered in_renderTableValue()
.As mentioned in #7177, there's nothing special about which types fall into
render
or_renderTableValue
, this organization just keeps things narrowed to how we actually use these types. If at some point we needcode
to be directly used, it's as simple as addingLH.Audit.Details.Code
to theLH.Audit.Details
type union and adding_renderCode()
back to theDetailsRenderer.render()
switch.