-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Conversation
There was a problem hiding this 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}; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
types/artifacts.d.ts
Outdated
responseReceivedTime: number; | ||
mimeType: string; | ||
}; | ||
resourceSize?: number; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, done
/** 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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Summary
Cleans up the
ImageUsage
artifact to remove unnecessary network record and align with other*Elements
artifacts.Related Issues/PRs
#6747