From 625f5baf3dcf91494a5eb80debddcc272d44c49c Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Wed, 12 Apr 2017 18:26:18 -0700 Subject: [PATCH 1/8] Adjust report-renderer init for devtools --- .../report/v2/renderer/details-renderer.js | 4 ++++ lighthouse-core/report/v2/renderer/dom.js | 14 ++++++++++++-- .../report/v2/renderer/report-renderer.js | 9 ++++++--- lighthouse-core/report/v2/report-template.html | 2 +- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lighthouse-core/report/v2/renderer/details-renderer.js b/lighthouse-core/report/v2/renderer/details-renderer.js index 129538dd2878..c008f102e3ac 100644 --- a/lighthouse-core/report/v2/renderer/details-renderer.js +++ b/lighthouse-core/report/v2/renderer/details-renderer.js @@ -15,6 +15,8 @@ */ 'use strict'; +/* globals self */ + class DetailsRenderer { /** * @param {!DOM} dom @@ -117,6 +119,8 @@ class DetailsRenderer { if (typeof module !== 'undefined' && module.exports) { module.exports = DetailsRenderer; +} else if (self) { + self.DetailsRenderer = DetailsRenderer; } /** @typedef {{type: string, text: string|undefined, header: DetailsJSON|undefined, items: Array|undefined}} */ diff --git a/lighthouse-core/report/v2/renderer/dom.js b/lighthouse-core/report/v2/renderer/dom.js index 4323f6708fe9..5713a252c146 100644 --- a/lighthouse-core/report/v2/renderer/dom.js +++ b/lighthouse-core/report/v2/renderer/dom.js @@ -15,7 +15,7 @@ */ 'use strict'; -/* globals URL */ +/* globals URL self */ class DOM { /** @@ -52,13 +52,21 @@ class DOM { * @throws {Error} */ cloneTemplate(selector) { - const template = this._document.querySelector(selector); + const template = this._retrieveTemplate(selector); if (!template) { throw new Error(`Template not found: template${selector}`); } return this._document.importNode(template.content, true); } + /** + * @param {string} selector + * @return {!DocumentFragment} The original template content + */ + _retrieveTemplate(selector) { + return this._document.querySelector(selector); + } + /** * @param {string} text * @return {!HTMLSpanElement} @@ -91,4 +99,6 @@ class DOM { if (typeof module !== 'undefined' && module.exports) { module.exports = DOM; +} else if (self) { + self.DOM = DOM; } diff --git a/lighthouse-core/report/v2/renderer/report-renderer.js b/lighthouse-core/report/v2/renderer/report-renderer.js index 58a87d413236..d599ab55f315 100644 --- a/lighthouse-core/report/v2/renderer/report-renderer.js +++ b/lighthouse-core/report/v2/renderer/report-renderer.js @@ -22,7 +22,7 @@ * Dummy text for ensuring report robustness: pre$`post %%LIGHTHOUSE_JSON%% */ -/* globals DOM, DetailsRenderer */ +/* globals self */ const RATINGS = { PASS: {label: 'pass', minScore: 75}, @@ -57,9 +57,10 @@ function formatNumber(number) { class ReportRenderer { /** * @param {!Document} document + * @param {!DOM} DOM + * @param {!DetailsRenderer} DetailsRenderer */ - constructor(document) { - this._dom = new DOM(document); + constructor(document, DOM, DetailsRenderer) { this._detailsRenderer = new DetailsRenderer(this._dom); } @@ -197,6 +198,8 @@ class ReportRenderer { if (typeof module !== 'undefined' && module.exports) { module.exports = ReportRenderer; +} else if (self) { + self.ReportRenderer = ReportRenderer; } /** @typedef {{id: string, weight: number, score: number, result: {description: string, displayValue: string, helpText: string, score: number|boolean, details: DetailsRenderer.DetailsJSON|DetailsRenderer.CardsDetailsJSON|undefined}}} */ diff --git a/lighthouse-core/report/v2/report-template.html b/lighthouse-core/report/v2/report-template.html index 019c68ff6090..e06c03e08d5e 100644 --- a/lighthouse-core/report/v2/report-template.html +++ b/lighthouse-core/report/v2/report-template.html @@ -30,7 +30,7 @@ From f9033ae537d9dceeb025e3edd2d88e8bd5e65ab6 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 13 Apr 2017 17:10:13 -0700 Subject: [PATCH 2/8] feedback. --- lighthouse-core/report/v2/renderer/details-renderer.js | 2 +- lighthouse-core/report/v2/renderer/dom.js | 2 +- lighthouse-core/report/v2/renderer/report-renderer.js | 8 ++++---- lighthouse-core/report/v2/report-template.html | 7 +++++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lighthouse-core/report/v2/renderer/details-renderer.js b/lighthouse-core/report/v2/renderer/details-renderer.js index c008f102e3ac..a0cce37dafab 100644 --- a/lighthouse-core/report/v2/renderer/details-renderer.js +++ b/lighthouse-core/report/v2/renderer/details-renderer.js @@ -119,7 +119,7 @@ class DetailsRenderer { if (typeof module !== 'undefined' && module.exports) { module.exports = DetailsRenderer; -} else if (self) { +} else { self.DetailsRenderer = DetailsRenderer; } diff --git a/lighthouse-core/report/v2/renderer/dom.js b/lighthouse-core/report/v2/renderer/dom.js index 5713a252c146..e6924f6e5328 100644 --- a/lighthouse-core/report/v2/renderer/dom.js +++ b/lighthouse-core/report/v2/renderer/dom.js @@ -99,6 +99,6 @@ class DOM { if (typeof module !== 'undefined' && module.exports) { module.exports = DOM; -} else if (self) { +} else { self.DOM = DOM; } diff --git a/lighthouse-core/report/v2/renderer/report-renderer.js b/lighthouse-core/report/v2/renderer/report-renderer.js index d599ab55f315..6f05ff7638ff 100644 --- a/lighthouse-core/report/v2/renderer/report-renderer.js +++ b/lighthouse-core/report/v2/renderer/report-renderer.js @@ -56,12 +56,12 @@ function formatNumber(number) { class ReportRenderer { /** - * @param {!Document} document * @param {!DOM} DOM * @param {!DetailsRenderer} DetailsRenderer */ - constructor(document, DOM, DetailsRenderer) { - this._detailsRenderer = new DetailsRenderer(this._dom); + constructor(dom, detailsRenderer) { + this._dom = dom; + this._detailsRenderer = detailsRenderer; } /** @@ -198,7 +198,7 @@ class ReportRenderer { if (typeof module !== 'undefined' && module.exports) { module.exports = ReportRenderer; -} else if (self) { +} else { self.ReportRenderer = ReportRenderer; } diff --git a/lighthouse-core/report/v2/report-template.html b/lighthouse-core/report/v2/report-template.html index e06c03e08d5e..627c4047f251 100644 --- a/lighthouse-core/report/v2/report-template.html +++ b/lighthouse-core/report/v2/report-template.html @@ -30,8 +30,11 @@ From 4ae044acbb0046a680b15a372caee3bb229687d5 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 13 Apr 2017 17:16:34 -0700 Subject: [PATCH 3/8] tests. --- .../test/report/v2/renderer/report-renderer-test.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lighthouse-core/test/report/v2/renderer/report-renderer-test.js b/lighthouse-core/test/report/v2/renderer/report-renderer-test.js index e6ae76038113..eaecb7fde651 100644 --- a/lighthouse-core/test/report/v2/renderer/report-renderer-test.js +++ b/lighthouse-core/test/report/v2/renderer/report-renderer-test.js @@ -33,16 +33,14 @@ describe('ReportRenderer V2', () => { before(() => { global.URL = URL; - global.DOM = DOM; - global.DetailsRenderer = DetailsRenderer; const document = jsdom.jsdom(TEMPLATE_FILE); - renderer = new ReportRenderer(document); + const dom = new DOM(document); + const detailsRenderer = new DetailsRenderer(dom); + renderer = new ReportRenderer(dom, detailsRenderer); }); after(() => { global.URL = undefined; - global.DOM = undefined; - global.DetailsRenderer = undefined; }); describe('renderReport', () => { From 96897b98ffbacde63c57f8bec5fe51ba8ef6c09d Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Thu, 13 Apr 2017 17:34:36 -0700 Subject: [PATCH 4/8] feedback and align with 2002 --- lighthouse-core/report/v2/renderer/dom.js | 11 ++--------- lighthouse-core/report/v2/renderer/report-renderer.js | 4 ++-- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/lighthouse-core/report/v2/renderer/dom.js b/lighthouse-core/report/v2/renderer/dom.js index e6924f6e5328..0d6adf8f1866 100644 --- a/lighthouse-core/report/v2/renderer/dom.js +++ b/lighthouse-core/report/v2/renderer/dom.js @@ -23,6 +23,7 @@ class DOM { */ constructor(document) { this._document = document; + this.templatesContext = this._document; } /** @@ -52,21 +53,13 @@ class DOM { * @throws {Error} */ cloneTemplate(selector) { - const template = this._retrieveTemplate(selector); + const template = this.templatesContext.querySelector(selector); if (!template) { throw new Error(`Template not found: template${selector}`); } return this._document.importNode(template.content, true); } - /** - * @param {string} selector - * @return {!DocumentFragment} The original template content - */ - _retrieveTemplate(selector) { - return this._document.querySelector(selector); - } - /** * @param {string} text * @return {!HTMLSpanElement} diff --git a/lighthouse-core/report/v2/renderer/report-renderer.js b/lighthouse-core/report/v2/renderer/report-renderer.js index 6f05ff7638ff..620cfa67c1a0 100644 --- a/lighthouse-core/report/v2/renderer/report-renderer.js +++ b/lighthouse-core/report/v2/renderer/report-renderer.js @@ -56,8 +56,8 @@ function formatNumber(number) { class ReportRenderer { /** - * @param {!DOM} DOM - * @param {!DetailsRenderer} DetailsRenderer + * @param {!DOM} dom + * @param {!DetailsRenderer} detailsRenderer */ constructor(dom, detailsRenderer) { this._dom = dom; From 15fe66879978d14fa5eecea0cbd95e36aa254de0 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Fri, 14 Apr 2017 15:56:46 -0700 Subject: [PATCH 5/8] typedefs on lock. and setTemplateContext --- .../report/v2/renderer/details-renderer.js | 36 +++++++--- lighthouse-core/report/v2/renderer/dom.js | 20 ++++-- .../report/v2/renderer/report-renderer.js | 69 +++++++++++++++---- 3 files changed, 93 insertions(+), 32 deletions(-) diff --git a/lighthouse-core/report/v2/renderer/details-renderer.js b/lighthouse-core/report/v2/renderer/details-renderer.js index a0cce37dafab..cee50e3c9285 100644 --- a/lighthouse-core/report/v2/renderer/details-renderer.js +++ b/lighthouse-core/report/v2/renderer/details-renderer.js @@ -45,7 +45,7 @@ class DetailsRenderer { } /** - * @param {!DetailsJSON} text + * @param {!DetailsRenderer.DetailsJSON} text * @return {!Element} */ _renderText(text) { @@ -55,19 +55,20 @@ class DetailsRenderer { } /** - * @param {!DetailsJSON} block + * @param {!DetailsRenderer.DetailsJSON} block * @return {!Element} */ _renderBlock(block) { const element = this._dom.createElement('div', 'lh-block'); - for (const item of block.items) { + const items = block.items || []; + for (const item of items) { element.appendChild(this.render(item)); } return element; } /** - * @param {!DetailsJSON} list + * @param {!DetailsRenderer.DetailsJSON} list * @return {!Element} */ _renderList(list) { @@ -78,11 +79,12 @@ class DetailsRenderer { element.appendChild(summary); } - const items = this._dom.createElement('div', 'lh-list__items'); - for (const item of list.items) { - items.appendChild(this.render(item)); + const itemsElem = this._dom.createElement('div', 'lh-list__items'); + const items = list.items || []; + for (const item of items) { + itemsElem.appendChild(this.render(item)); } - element.appendChild(items); + element.appendChild(itemsElem); return element; } @@ -123,9 +125,21 @@ if (typeof module !== 'undefined' && module.exports) { self.DetailsRenderer = DetailsRenderer; } -/** @typedef {{type: string, text: string|undefined, header: DetailsJSON|undefined, items: Array|undefined}} */ +/** + * @typedef {{ + * type: string, + * text: (string|undefined), + * header: (DetailsRenderer.DetailsJSON|undefined), + * items: (!Array|undefined) + * }} + */ DetailsRenderer.DetailsJSON; // eslint-disable-line no-unused-expressions - -/** @typedef {{type: string, text: string, header: DetailsJSON, items: Array<{title: string, value: string, snippet: string|undefined, target: string}>}} */ +/** @typedef {{ + * type: string, + * text: string, + * header: DetailsJSON, + * items: Array<{title: string, value: string, snippet: string|undefined, target: string}> + * }} + */ DetailsRenderer.CardsDetailsJSON; // eslint-disable-line no-unused-expressions diff --git a/lighthouse-core/report/v2/renderer/dom.js b/lighthouse-core/report/v2/renderer/dom.js index 0d6adf8f1866..5c1a798cf856 100644 --- a/lighthouse-core/report/v2/renderer/dom.js +++ b/lighthouse-core/report/v2/renderer/dom.js @@ -23,7 +23,6 @@ class DOM { */ constructor(document) { this._document = document; - this.templatesContext = this._document; } /** @@ -34,7 +33,8 @@ class DOM { * set the attribute on the node. * @return {!Element} */ - createElement(name, className, attrs = {}) { + createElement(name, className, attrs) { + attrs = attrs || {}; const element = this._document.createElement(name); if (className) { element.className = className; @@ -49,20 +49,21 @@ class DOM { /** * @param {string} selector + * @param {!Document|!Element} context * @return {!DocumentFragment} A clone of the template content. * @throws {Error} */ - cloneTemplate(selector) { - const template = this.templatesContext.querySelector(selector); + cloneTemplate(selector, context) { + const template = context.querySelector(selector); if (!template) { throw new Error(`Template not found: template${selector}`); } - return this._document.importNode(template.content, true); + return /** @type {!DocumentFragment} */ (this._document.importNode(template.content, true)); } /** * @param {string} text - * @return {!HTMLSpanElement} + * @return {!Element} */ createSpanFromMarkdown(text) { const element = this.createElement('span'); @@ -88,6 +89,13 @@ class DOM { return element; } + + /** + * @return {!Document} + */ + document() { + return this._document; + } } if (typeof module !== 'undefined' && module.exports) { diff --git a/lighthouse-core/report/v2/renderer/report-renderer.js b/lighthouse-core/report/v2/renderer/report-renderer.js index 620cfa67c1a0..801960b91b3a 100644 --- a/lighthouse-core/report/v2/renderer/report-renderer.js +++ b/lighthouse-core/report/v2/renderer/report-renderer.js @@ -62,10 +62,12 @@ class ReportRenderer { constructor(dom, detailsRenderer) { this._dom = dom; this._detailsRenderer = detailsRenderer; + + this._templateContext = this._dom.document(); } /** - * @param {!ReportJSON} report + * @param {!ReportRenderer.ReportJSON} report * @return {!Element} */ renderReport(report) { @@ -95,15 +97,22 @@ class ReportRenderer { element.querySelector('.lh-score__description') .appendChild(this._dom.createSpanFromMarkdown(description)); - return element; + return /** @type {!Element} **/ (element); + } + + /** + * @param {!Document|!Element} context + */ + setTemplateContext(context) { + this._templateContext = context; } /** - * @param {!AuditJSON} audit + * @param {!ReportRenderer.AuditJSON} audit * @return {!Element} */ _renderAuditScore(audit) { - const tmpl = this._dom.cloneTemplate('#tmpl-lh-audit-score'); + const tmpl = this._dom.cloneTemplate('#tmpl-lh-audit-score', this._templateContext); const scoringMode = audit.result.scoringMode; const description = audit.result.helpText; @@ -127,11 +136,11 @@ class ReportRenderer { } /** - * @param {!CategoryJSON} category + * @param {!ReportRenderer.CategoryJSON} category * @return {!Element} */ _renderCategoryScore(category) { - const tmpl = this._dom.cloneTemplate('#tmpl-lh-category-score'); + const tmpl = this._dom.cloneTemplate('#tmpl-lh-category-score', this._templateContext); const score = Math.round(category.score); return this._populateScore(tmpl, score, 'numeric', category.name, category.description); } @@ -147,7 +156,7 @@ class ReportRenderer { } /** - * @param {!ReportJSON} report + * @param {!ReportRenderer.ReportJSON} report * @return {!Element} */ _renderReport(report) { @@ -159,7 +168,7 @@ class ReportRenderer { } /** - * @param {!CategoryJSON} category + * @param {!ReportRenderer.CategoryJSON} category * @return {!Element} */ _renderCategory(category) { @@ -186,7 +195,7 @@ class ReportRenderer { } /** - * @param {!AuditJSON} audit + * @param {!ReportRenderer.AuditJSON} audit * @return {!Element} */ _renderAudit(audit) { @@ -202,11 +211,41 @@ if (typeof module !== 'undefined' && module.exports) { self.ReportRenderer = ReportRenderer; } -/** @typedef {{id: string, weight: number, score: number, result: {description: string, displayValue: string, helpText: string, score: number|boolean, details: DetailsRenderer.DetailsJSON|DetailsRenderer.CardsDetailsJSON|undefined}}} */ -let AuditJSON; // eslint-disable-line no-unused-vars +/** + * @typedef {{ + * id: string, weight: + * number, score: number, + * result: { + * description: string, + * displayValue: string, + * helpText: string, + * score: (number|boolean), + * scoringMode: string, + * details: (DetailsRenderer.DetailsJSON|DetailsRenderer.CardsDetailsJSON|undefined) + * } + * }} + */ +ReportRenderer.AuditJSON; // eslint-disable-line no-unused-expressions -/** @typedef {{name: string, weight: number, score: number, description: string, audits: Array}} */ -let CategoryJSON; // eslint-disable-line no-unused-vars +/** + * @typedef {{ + * name: string, + * weight: number, + * score: number, + * description: string, + * audits: Array + * }} + */ +ReportRenderer.CategoryJSON; // eslint-disable-line no-unused-expressions -/** @typedef {{reportCategories: Array}} */ -let ReportJSON; // eslint-disable-line no-unused-vars +/** + * @typedef {{ + * lighthouseVersion: !string, + * generatedTime: !string, + * initialUrl: !string, + * url: !string, + * audits: ?Object, + * reportCategories: !Array + * }} + */ +ReportRenderer.ReportJSON; // eslint-disable-line no-unused-expressions From 70b50ccf56fa902a745e3daed1458190e45eabc3 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Fri, 14 Apr 2017 16:04:36 -0700 Subject: [PATCH 6/8] tests for cloneTemplate. --- lighthouse-core/test/report/v2/renderer/dom-test.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lighthouse-core/test/report/v2/renderer/dom-test.js b/lighthouse-core/test/report/v2/renderer/dom-test.js index b1c711a20139..625efadf7ee0 100644 --- a/lighthouse-core/test/report/v2/renderer/dom-test.js +++ b/lighthouse-core/test/report/v2/renderer/dom-test.js @@ -58,12 +58,16 @@ describe('DOM', () => { describe('cloneTemplate', () => { it('should clone a template', () => { - const clone = dom.cloneTemplate('#tmpl-lh-audit-score'); + const clone = dom.cloneTemplate('#tmpl-lh-audit-score', dom.document()); assert.ok(clone.querySelector('.lh-score')); }); it('fails when template cannot be found', () => { - assert.throws(() => dom.cloneTemplate('#unknown-selector')); + assert.throws(() => dom.cloneTemplate('#unknown-selector', dom.document())); + }); + + it('fails when a template context isn\'t provided', () => { + assert.throws(() => dom.cloneTemplate('#tmpl-lh-audit-score')); }); }); From 0765b358a141701f01c3b4807ab41515c3f5e129 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Fri, 14 Apr 2017 16:08:03 -0700 Subject: [PATCH 7/8] tests for renderer.setTemplateContext --- .../test/report/v2/renderer/report-renderer-test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lighthouse-core/test/report/v2/renderer/report-renderer-test.js b/lighthouse-core/test/report/v2/renderer/report-renderer-test.js index eaecb7fde651..1575a5100f88 100644 --- a/lighthouse-core/test/report/v2/renderer/report-renderer-test.js +++ b/lighthouse-core/test/report/v2/renderer/report-renderer-test.js @@ -94,4 +94,12 @@ describe('ReportRenderer V2', () => { assert.equal(audits.length, category.audits.length, 'renders correct number of audits'); }); }); + + it('can set a custom templateContext', () => { + assert.equal(renderer._templateContext, renderer._dom.document()); + + const otherDocument = jsdom.jsdom(TEMPLATE_FILE); + renderer.setTemplateContext(otherDocument); + assert.equal(renderer._templateContext, otherDocument); + }); }); From 46db6a3bc2d27fcba3a0b2426ea63cbf56918c88 Mon Sep 17 00:00:00 2001 From: Paul Irish Date: Fri, 14 Apr 2017 16:55:09 -0700 Subject: [PATCH 8/8] feedback and compile in devtools is good. --- lighthouse-core/report/v2/renderer/details-renderer.js | 10 +++++----- lighthouse-core/report/v2/renderer/dom.js | 6 ++++-- lighthouse-core/report/v2/renderer/report-renderer.js | 6 ++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lighthouse-core/report/v2/renderer/details-renderer.js b/lighthouse-core/report/v2/renderer/details-renderer.js index cee50e3c9285..ebf15a4650d5 100644 --- a/lighthouse-core/report/v2/renderer/details-renderer.js +++ b/lighthouse-core/report/v2/renderer/details-renderer.js @@ -36,7 +36,7 @@ class DetailsRenderer { case 'block': return this._renderBlock(details); case 'cards': - return this._renderCards(details); + return this._renderCards(/** @type {!DetailsRenderer.CardsDetailsJSON} */ (details)); case 'list': return this._renderList(details); default: @@ -89,7 +89,7 @@ class DetailsRenderer { } /** - * @param {!CardsDetailsJSON} details + * @param {!DetailsRenderer.CardsDetailsJSON} details * @return {!Element} */ _renderCards(details) { @@ -129,7 +129,7 @@ if (typeof module !== 'undefined' && module.exports) { * @typedef {{ * type: string, * text: (string|undefined), - * header: (DetailsRenderer.DetailsJSON|undefined), + * header: (!DetailsRenderer.DetailsJSON|undefined), * items: (!Array|undefined) * }} */ @@ -138,8 +138,8 @@ DetailsRenderer.DetailsJSON; // eslint-disable-line no-unused-expressions /** @typedef {{ * type: string, * text: string, - * header: DetailsJSON, - * items: Array<{title: string, value: string, snippet: string|undefined, target: string}> + * header: !DetailsRenderer.DetailsJSON, + * items: !Array<{title: string, value: string, snippet: (string|undefined), target: string}> * }} */ DetailsRenderer.CardsDetailsJSON; // eslint-disable-line no-unused-expressions diff --git a/lighthouse-core/report/v2/renderer/dom.js b/lighthouse-core/report/v2/renderer/dom.js index 5c1a798cf856..0b3ea063a4bb 100644 --- a/lighthouse-core/report/v2/renderer/dom.js +++ b/lighthouse-core/report/v2/renderer/dom.js @@ -34,14 +34,16 @@ class DOM { * @return {!Element} */ createElement(name, className, attrs) { + // TODO(all): adopt `attrs` default arg when https://codereview.chromium.org/2821773002/ lands attrs = attrs || {}; const element = this._document.createElement(name); if (className) { element.className = className; } Object.keys(attrs).forEach(key => { - if (attrs[key] !== undefined) { - element.setAttribute(key, attrs[key]); + const value = attrs[key]; + if (typeof value !== 'undefined') { + element.setAttribute(key, value); } }); return element; diff --git a/lighthouse-core/report/v2/renderer/report-renderer.js b/lighthouse-core/report/v2/renderer/report-renderer.js index 801960b91b3a..a6d1507fd058 100644 --- a/lighthouse-core/report/v2/renderer/report-renderer.js +++ b/lighthouse-core/report/v2/renderer/report-renderer.js @@ -101,6 +101,8 @@ class ReportRenderer { } /** + * Define a custom element for to be extracted from. For example: + * this.setTemplateContext(new DOMParser().parseFromString(htmlStr, 'text/html')) * @param {!Document|!Element} context */ setTemplateContext(context) { @@ -221,7 +223,7 @@ if (typeof module !== 'undefined' && module.exports) { * helpText: string, * score: (number|boolean), * scoringMode: string, - * details: (DetailsRenderer.DetailsJSON|DetailsRenderer.CardsDetailsJSON|undefined) + * details: (!DetailsRenderer.DetailsJSON|!DetailsRenderer.CardsDetailsJSON|undefined) * } * }} */ @@ -233,7 +235,7 @@ ReportRenderer.AuditJSON; // eslint-disable-line no-unused-expressions * weight: number, * score: number, * description: string, - * audits: Array + * audits: !Array * }} */ ReportRenderer.CategoryJSON; // eslint-disable-line no-unused-expressions