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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

core(unsized-images): respect CSS rules from stylesheets #11590

Merged
merged 2 commits into from Oct 23, 2020

Conversation

patrickhulce
Copy link
Collaborator

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 prefer if (!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 :)

@patrickhulce patrickhulce requested a review from a team as a code owner October 23, 2020 02:18
@patrickhulce patrickhulce requested review from adamraine and removed request for a team October 23, 2020 02:18
@google-cla google-cla bot added the cla: yes label Oct 23, 2020
<!-- 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 -->
Copy link
Collaborator Author

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
Copy link
Collaborator Author

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

Copy link
Member

@adamraine adamraine left a 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) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: style => rule

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

Successfully merging this pull request may close these issues.

None yet

3 participants