Skip to content

Commit

Permalink
feedback WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed May 4, 2017
1 parent b2b18fe commit bda482b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 15 deletions.
32 changes: 23 additions & 9 deletions lighthouse-core/audits/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class Audit {
* Table cells will use the type specified in headings[x].itemType. However a custom type
* can be provided: results[x].propName = {type: 'code', text: '...'}
* @param {!Audit.Headings} headings
* @param {!Array<!Object<string, string>>} results
* @param {!Array<!Object<string, *>>} results
* @return {!Array<!DetailsRenderer.DetailsJSON>}
*/
static makeV2TableRows(headings, results) {
Expand Down Expand Up @@ -157,13 +157,27 @@ class Audit {

module.exports = Audit;

/** @typedef {{
* key: string,
* itemType: string,
* text: string,
* }}
/** @typedef {
* !Array<{
* key: string,
* itemType: string,
* text: string,
* }>}
*/
Audit.Heading; // eslint-disable-line no-unused-expressions

/** @typedef {!Array<!Audit.Heading>} */
Audit.Headings; // eslint-disable-line no-unused-expressions


{{results: !Array<Object>, headings: !Audit.Headings, passes: boolean, debugString: (string|undefined)}}
{{results: !Array<Object>, passes: boolean=, headings: !Audit.Headings, debugString: string=}}
{{results: !Array<Object>, headings: !Audit.Headings, passes: boolean, debugString: string=}}
{!{debugString: string=, passes: boolean=, headings: !Audit.Headings, results: !Array<!Object<string, string>>}} result

/** @typedef {
* {{
* results: !Array<Object>,
* headings: !Audit.Headings,
* passes: boolean,
* debugString: (string|undefined)
* }}
*/
Audit.; // eslint-disable-line no-unused-expressions
2 changes: 1 addition & 1 deletion lighthouse-core/audits/byte-efficiency/offscreen-images.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class OffscreenImages extends ByteEfficiencyAudit {

/**
* @param {!Artifacts} artifacts
* @return {{results: !Array<Object>, headings: !Audit.Headings, debugString: string=}}
* @return {{results: !Array<Object>, headings: !Audit.Headings, passes: boolean, debugString: (string|undefined)}}
*/
static audit_(artifacts) {
const images = artifacts.ImageUsage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class UsesOptimizedImages extends ByteEfficiencyAudit {

/**
* @param {!Artifacts} artifacts
* @return {{results: !Array<Object>, headings: !Audit.Headings, passes: boolean=, debugString: string=}}
* @return {{results: !Array<Object>, headings: !Audit.Headings, passes: boolean, debugString: (string|undefined)}}
*/
static audit_(artifacts) {
const images = artifacts.OptimizedImages;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ResponsesAreCompressed extends ByteEfficiencyAudit {
/**
* @param {!Artifacts} artifacts
* @param {number} networkThroughput
* @return {{results: !Array<Object>, passes: boolean=, headings: !Audit.Headings, debugString: string=}}
* @return {{results: !Array<Object>, headings: !Audit.Headings, passes: boolean, debugString: (string|undefined)}}
*/
static audit_(artifacts) {
const uncompressedResponses = artifacts.ResponseCompression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class UsesResponsiveImages extends ByteEfficiencyAudit {

/**
* @param {!Artifacts} artifacts
* @return {{results: !Array<Object>, headings: !Audit.Headings, passes: boolean=, debugString: string=}}
* @return {{results: !Array<Object>, headings: !Audit.Headings, passes: boolean, debugString: (string|undefined)}}
*/
static audit_(artifacts) {
const images = artifacts.ImageUsage;
Expand Down
6 changes: 4 additions & 2 deletions lighthouse-core/report/v2/renderer/details-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,19 @@ class DetailsRenderer {
}

/**
* Create small thumbnail with scaled down image asset.
* If the supplied details doesn't have an image/* mimeType, then an empty span is returned.
* @param {!DetailsRenderer.ThumbnailDetails} value
* @return {!Element}
*/
_renderThumbnail(value) {
if (/^image/.test(value.mimeType) === false) {
if (!value.mimeType.startsWith('image/')) {
return this._dom.createElement('span');
}

const element = this._dom.createElement('img', 'lh-thumbnail');
element.src = value.url;
element.alt = 'Image preview';
element.alt = '';
element.title = value.url;
return element;
}
Expand Down

0 comments on commit bda482b

Please sign in to comment.