-
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: eliminate cards and list details #4789
Changes from 2 commits
971b855
c9cc2a5
aa28278
e113932
0941df8
5ad0284
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,24 +47,15 @@ class DOMSize extends Audit { | |
}; | ||
} | ||
|
||
|
||
/** | ||
* @param {!Artifacts} artifacts | ||
* @return {!AuditResult} | ||
*/ | ||
static audit(artifacts) { | ||
const stats = artifacts.DOMStats; | ||
|
||
/** | ||
* html > | ||
* body > | ||
* div > | ||
* span | ||
*/ | ||
const depthSnippet = stats.depth.pathToElement.reduce((str, curr, i) => { | ||
return `${str}\n` + ' '.repeat(i) + `${curr} >`; | ||
}, '').replace(/>$/g, '').trim(); | ||
const widthSnippet = 'Element with most children:\n' + | ||
stats.width.pathToElement[stats.width.pathToElement.length - 1]; | ||
const depthSnippet = stats.depth.pathToElement.join(' > '); | ||
const widthSnippet = stats.width.pathToElement.join(' > '); | ||
|
||
// Use the CDF of a log-normal distribution for scoring. | ||
// <= 1500: score≈1 | ||
|
@@ -76,34 +67,28 @@ class DOMSize extends Audit { | |
SCORING_MEDIAN | ||
); | ||
|
||
const cards = [{ | ||
title: 'Total DOM Nodes', | ||
value: Util.formatNumber(stats.totalDOMNodes), | ||
target: `< ${Util.formatNumber(MAX_DOM_NODES)} nodes`, | ||
}, { | ||
title: 'DOM Depth', | ||
value: Util.formatNumber(stats.depth.max), | ||
snippet: depthSnippet, | ||
target: `< ${Util.formatNumber(MAX_DOM_TREE_DEPTH)}`, | ||
}, { | ||
title: 'Maximum Children', | ||
value: Util.formatNumber(stats.width.max), | ||
snippet: widthSnippet, | ||
target: `< ${Util.formatNumber(MAX_DOM_TREE_WIDTH)} nodes`, | ||
}]; | ||
const headings = [ | ||
{key: 'totalNodes', itemType: 'text', text: 'Total DOM Nodes'}, | ||
{key: 'depth', itemType: 'text', text: 'DOM Depth'}, | ||
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. let's add "Maximum" to this title 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. done |
||
{key: 'width', itemType: 'text', text: 'Maximum Children'}, | ||
]; | ||
|
||
const items = [ | ||
{ | ||
totalNodes: Util.formatNumber(stats.totalDOMNodes), | ||
depth: `${Util.formatNumber(stats.depth.max)} (${depthSnippet})`, | ||
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. i dont know if this display will scale. e.g: fwiw here is the same with the card: url is https://tinyhousebuild.com/ btw 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.
just saw below I like outer HTML 👍 |
||
width: `${Util.formatNumber(stats.width.max)} (${widthSnippet})`, | ||
}, | ||
]; | ||
|
||
return { | ||
score, | ||
rawValue: stats.totalDOMNodes, | ||
displayValue: `${Util.formatNumber(stats.totalDOMNodes)} nodes`, | ||
extendedInfo: { | ||
value: cards, | ||
}, | ||
details: { | ||
type: 'cards', | ||
header: {type: 'text', text: 'View details'}, | ||
items: cards, | ||
value: items, | ||
}, | ||
details: Audit.makeTableDetails(headings, items), | ||
}; | ||
} | ||
} | ||
|
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.
for the snippet i think we could simplify by providing the outerhtml snippet like
lighthouse/lighthouse-core/gather/gatherers/accessibility.js
Lines 76 to 85 in 7c7695b
and forget this selector thing that will never scale.
i dont think this SOLVES the scaling problem, but it helps. maybe we put these snippets on a new row?
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.
yeah agreed this is better 👍 I think we solve this with a new type in fancy report land with the other page stats (# network requests, etc)
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.
I tried to get fancy and make it a proper node type but that looks a bit wonky as they get left-aligned while text right-aligned
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.
here's it as text which is what I'm going with for now, I expect this to change before 3.0 anyhow