Skip to content

fix(challenge): use offsetHeight to get height value - #36995

Merged
RandellDawson merged 1 commit into
freeCodeCamp:masterfrom
lasjorg:fix/adjust-the-height-of-an-element-using-the-height-property
Oct 27, 2019
Merged

RandellDawson merged 1 commit into
freeCodeCamp:masterfrom
lasjorg:fix/adjust-the-height-of-an-element-using-the-height-property

Conversation

@lasjorg

@lasjorg lasjorg commented Oct 3, 2019 •

Copy link
Copy Markdown
Contributor
  • 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.
  • None of my changes are plagiarized from another source without proper attribution.
  • All the files I changed are in the same world language (for example: only English changes, or only Chinese changes, etc.)
  • My changes do not use shortened URLs or affiliate links.

The challenge test relies on getComputedStyle (jquery css() function) which, for height at least, may not return a reliable result. There are reported cases of this failing and returning decimal numbers. This fix replaces css() with element.offsetHeight.

I should note that as I can't reproduce this bug, I can't reliably test if this is a solution either. I believe it is very likely to be a fix but it would be nice to get some confirmation. I have posted in the forum and may be able to get some data back.

Note: The challenge also has a width counterpart challenge, which is using the same reliance on getComputedStyle. I have not seen any bug reports for it. But that doesn't mean there aren't any and it may need the same fix.

Adjust the Width of an Element Using the width Property
https://learn.freecodecamp.org/responsive-web-design/applied-visual-design/adjust-the-width-of-an-element-using-the-width-property

Closes #18045

@gitpod-io

gitpod-io Bot commented Oct 3, 2019

Copy link
Copy Markdown

@lasjorg

lasjorg commented Oct 3, 2019 •

Copy link
Copy Markdown
Contributor Author

I believe I have confirmation that getComputedStyle is in some cases returning a decimal number and that using offsetHeight will fix this.

https://www.freecodecamp.org/forum/t/help-to-adjust-the-height-of-an-element-using-the-height-property/319027/13

@camperbot camperbot added language: English scope: curriculum Lessons, Challenges, Projects and other Curricular Content in curriculum directory. labels Oct 4, 2019
@scissorsneedfoodtoo

Copy link
Copy Markdown
Contributor

Thank you for your thorough investigation and fix for this issue, @lasjorg. Tested on GitPod and everything LGTM.

@RandellDawson
RandellDawson merged commit 316d56b into freeCodeCamp:master Oct 27, 2019
@RandellDawson

Copy link
Copy Markdown
Member

Thank you for your contribution to the page! 👍
We're happy to accept these changes, and look forward to future contributions. 🎉

@lasjorg
lasjorg deleted the fix/adjust-the-height-of-an-element-using-the-height-property branch November 5, 2019 04:15
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.

Applied Visual Design: Adjust the Height of an Element Using the height Property - correct solution does not pass

4 participants