core(images): cleanup ImageUsage to match other *Elements artifacts#7030
Merged
Conversation
brendankenny
approved these changes
Jan 17, 2019
| 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}; |
Contributor
There was a problem hiding this comment.
wait, is this just for resourceSize and mimeType? :P
| responseReceivedTime: number; | ||
| mimeType: string; | ||
| }; | ||
| resourceSize?: number; |
Contributor
There was a problem hiding this comment.
this default's to 0 so no need to be optional?
| const networkRecord = indexedNetworkRecords[element.src] || {}; | ||
| element.mimeType = networkRecord.mimeType; | ||
| const {resourceSize = 0, transferSize = 0} = networkRecord; | ||
| element.resourceSize = Math.min(resourceSize, transferSize); |
Contributor
There was a problem hiding this comment.
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?
| /** 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; |
Collaborator
There was a problem hiding this comment.
are these set when the image is from css?
Collaborator
Author
There was a problem hiding this comment.
yes it falls back to clientHeight/clientWidth in that case
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cleans up the
ImageUsageartifact to remove unnecessary network record and align with other*Elementsartifacts.Related Issues/PRs
#6747