Skip to content
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

core(images): cleanup ImageUsage to match other *Elements artifacts #7030

Merged
merged 4 commits into from
Jan 17, 2019

Conversation

patrickhulce
Copy link
Collaborator

Summary
Cleans up the ImageUsage artifact to remove unnecessary network record and align with other *Elements artifacts.

Related Issues/PRs
#6747

@paulirish paulirish mentioned this pull request Jan 16, 2019
6 tasks
Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@@ -18,7 +18,7 @@ function generateRecord(url = 'https://google.com/logo.png', mimeType = 'image/p

function generateImage(clientSize, naturalSize, networkRecord, props, src = 'https://google.com/logo.png') {
Object.assign(networkRecord || {}, {url: src});
const image = {src, networkRecord};
const image = {src, ...networkRecord};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, is this just for resourceSize and mimeType? :P

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

responseReceivedTime: number;
mimeType: string;
};
resourceSize?: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this default's to 0 so no need to be optional?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

const networkRecord = indexedNetworkRecords[element.src] || {};
element.mimeType = networkRecord.mimeType;
const {resourceSize = 0, transferSize = 0} = networkRecord;
element.resourceSize = Math.min(resourceSize, transferSize);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we didn't have one before, but mind putting a comment on this about the goal/why it's ok to fall back to transferSize?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, done

@patrickhulce patrickhulce merged commit 33de42b into master Jan 17, 2019
@patrickhulce patrickhulce deleted the image_elements branch January 17, 2019 17:46
/** The displayed width of the image, uses img.width when available falling back to clientWidth. See https://codepen.io/patrickhulce/pen/PXvQbM for examples. */
displayedWidth: number;
/** The displayed height of the image, uses img.height when available falling back to clientHeight. See https://codepen.io/patrickhulce/pen/PXvQbM for examples. */
displayedHeight: number;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these set when the image is from css?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it falls back to clientHeight/clientWidth in that case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants