Skip to content

fix: tests for use a retina image challenge - #39133

Merged
moT01 merged 1 commit into
freeCodeCamp:masterfrom
scissorsneedfoodtoo:fix/use-a-retina-image-challenge-tests
Aug 30, 2020
Merged

moT01 merged 1 commit into
freeCodeCamp:masterfrom
scissorsneedfoodtoo:fix/use-a-retina-image-challenge-tests

Conversation

@scissorsneedfoodtoo

Copy link
Copy Markdown
Contributor

Checklist:

  • I have read freeCodeCamp's contribution guidelines.
  • My pull request has a descriptive title (not a vague title like Update index.md)
  • My pull request targets the master branch of freeCodeCamp.
  • All the files I changed are in the same world language, for example: only English changes, or only Chinese changes, etc.

Closes #XXXXX

We've gotten a couple of reports about this challenge in the support email. On my machine (Linux Mint 19.3), the current tests fail in Chrome (83.0.4103.116), but pass in Firefox (77.0.1).

In Chrome's dev console, the height and width of the image are both 99.986px rather than 100px, even after playing with the zoom. These changes look at the actual width and height attributes of the image, and should still allow for answers like max-width: 100px;.

@gitpod-io

gitpod-io Bot commented Jun 25, 2020

Copy link
Copy Markdown

@ShaunSHamilton

Copy link
Copy Markdown
Member

Hey @scissorsneedfoodtoo , my understanding is that, this will not make the difference either, and you need to use:

element.style.width

To consistently retrieve the given value

@scissorsneedfoodtoo

Copy link
Copy Markdown
Contributor Author

Hi @SKY020, thanks for looking into this.

I just tried with the element.style.width method, but only got empty strings. As far as I can tell, the style property is just for getting inline styles, or those that were set dynamically.

I also tried with getComputedStyle, but ended up getting 99.9862px in Chrome which we're trying to avoid. We could use getComputedStyle, strip px from the string, convert it to a number and round it, though.

Not really sure what the best method would be other than testing the width and height attributes directly.

@ShaunSHamilton

Copy link
Copy Markdown
Member

the style property is just for getting inline styles, or those that were set dynamically.

You are quite right.

Not really sure what the best method would be other than testing the width and height attributes directly.

I suppose, if this PR corrects the issue on a few more browsers, and we do not want to go through the hassle of using regex, then this PR is useful as is.

@ShaunSHamilton ShaunSHamilton left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 👍

@thecodingaviator

Copy link
Copy Markdown
Contributor

I also tried with getComputedStyle, but ended up getting 99.9862px in Chrome which we're trying to avoid. We could use getComputedStyle, strip px from the string, convert it to a number and round it, though.

We've had this problem before too, I believe. It was because jQuery uses getComputedStyle as far as I remember.

@camperbot camperbot added language: English scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. labels Jul 1, 2020

@moT01 moT01 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM 🎉

I have gotten the okay to merge PR's in this section that don't change text that might be translated so I am going to merge this.

@moT01
moT01 merged commit b731563 into freeCodeCamp:master Aug 30, 2020
@scissorsneedfoodtoo
scissorsneedfoodtoo deleted the fix/use-a-retina-image-challenge-tests branch August 31, 2020 07:26
@scissorsneedfoodtoo

Copy link
Copy Markdown
Contributor Author

Thanks for the merge @moT01 👍 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants