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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
core(unsized-images): respect CSS rules from stylesheets #11590
Conversation
<!-- PASS(responsive): image is used at full size --> | ||
<!-- PASS(responsive-inverse): image does not account for DPR 2.625 --> | ||
<!-- PASS(offscreen): image is lazily loaded --> | ||
<!-- PASS(unsized-images): CSS sizing from stylesheet, not inline --> |
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 was failing before the fix
@@ -66,7 +66,7 @@ function computeSelectorSpecificity(selector) { | |||
/** | |||
* Finds the most specific directly matched CSS font-size rule from the list. | |||
* | |||
* @param {Array<LH.Crdp.CSS.RuleMatch>} [matchedCSSRules] | |||
* @param {Array<LH.Crdp.CSS.RuleMatch>} matchedCSSRules |
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 causes vscode to complain about ordering of optional arguments
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.
Overall LGTM
@@ -177,12 +177,12 @@ function determineNaturalSize(url) { | |||
} | |||
|
|||
/** | |||
* @param {LH.Crdp.CSS.CSSStyle|undefined} style | |||
* @param {Partial<Pick<LH.Crdp.CSS.CSSStyle, 'cssProperties'>>|undefined} style | |||
* @param {string} property | |||
* @return {string | undefined} | |||
*/ | |||
function findSizeDeclaration(style, property) { |
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.
nit: style
=> rule
Summary
CSS rules from stylesheets were being completely ignored due to an errant
ts-expect-error
, the explanation sounded so reasonable but it was referencing a property name that didn't even exist. Yet another reminder to preferif (!foo) throw new Error('Impossible')
over@ts-expect-error
馃槃Also drive-by fix for AVIF getting incorrectly mime type sniffed.
Related Issues/PRs
fixes https://twitter.com/andreasbovens/status/1319411834865262594 :)