Skip to content

Commit

Permalink
Merge 3c606a4 into 8caa938
Browse files Browse the repository at this point in the history
  • Loading branch information
adamraine committed Oct 14, 2020
2 parents 8caa938 + 3c606a4 commit 3a74b45
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,11 @@ const expectations = [
numericValue: 148,
details: {
items: [
{statistic: 'Total DOM Elements', value: '148'},
{statistic: 'Maximum DOM Depth', value: '4'},
{statistic: 'Total DOM Elements', value: 148},
{statistic: 'Maximum DOM Depth', value: 4},
{
statistic: 'Maximum Child Elements',
value: '100',
value: 100,
element: {value: '<div id="shadow-root-container">'},
},
],
Expand Down
10 changes: 3 additions & 7 deletions lighthouse-core/audits/dobetterweb/dom-size.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
'use strict';

const Audit = require('../audit.js');
const I18n = require('../../report/html/renderer/i18n.js');
const i18n_ = require('../../lib/i18n/i18n.js');

const UIStrings = {
Expand Down Expand Up @@ -92,31 +91,28 @@ class DOMSize extends Audit {
{key: 'value', itemType: 'numeric', text: str_(UIStrings.columnValue)},
];

const i18n = new I18n(context.settings.locale);

/** @type {LH.Audit.Details.Table['items']} */
const items = [
{
statistic: str_(UIStrings.statisticDOMElements),
element: '',
// TODO: these values should be numbers once `_renderNumeric` in details-renderer can handle them
value: i18n.formatNumber(stats.totalBodyElements),
value: stats.totalBodyElements,
},
{
statistic: str_(UIStrings.statisticDOMDepth),
element: {
type: 'code',
value: stats.depth.snippet,
},
value: i18n.formatNumber(stats.depth.max),
value: stats.depth.max,
},
{
statistic: str_(UIStrings.statisticDOMWidth),
element: {
type: 'code',
value: stats.width.snippet,
},
value: i18n.formatNumber(stats.width.max),
value: stats.width.max,
},
];

Expand Down
6 changes: 3 additions & 3 deletions lighthouse-core/test/audits/dobetterweb/dom-size-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ describe('DOMSize audit', () => {
assert.equal(auditResult.score, 0.43);
assert.equal(auditResult.numericValue, numElements);
expect(auditResult.displayValue).toBeDisplayString('1,500 elements');
assert.equal(auditResult.details.items[0].value, numElements.toLocaleString());
assert.equal(auditResult.details.items[1].value, '1');
assert.equal(auditResult.details.items[2].value, '2');
assert.equal(auditResult.details.items[0].value, numElements);
assert.equal(auditResult.details.items[1].value, 1);
assert.equal(auditResult.details.items[2].value, 2);
});

it('calculates score hitting top distribution', () => {
Expand Down
6 changes: 3 additions & 3 deletions lighthouse-core/test/results/sample_v2.json
Original file line number Diff line number Diff line change
Expand Up @@ -3626,23 +3626,23 @@
{
"statistic": "Total DOM Elements",
"element": "",
"value": "31"
"value": 31
},
{
"statistic": "Maximum DOM Depth",
"element": {
"type": "code",
"value": "<h2>"
},
"value": "3"
"value": 3
},
{
"statistic": "Maximum Child Elements",
"element": {
"type": "code",
"value": "<body>"
},
"value": "29"
"value": 29
}
]
}
Expand Down

0 comments on commit 3a74b45

Please sign in to comment.