| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
rgbToHsl aliased its argument with colorHsl = colorRgb instead of copying it, then overwrote colorHsl in place and returned that same array, destroying the caller's original RGB values. Copy the input with [...colorRgb] instead, and add a regression test asserting the input is left unchanged.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## master #1908 +/- ##
=======================================
Coverage 85.91% 85.91%
=======================================
Files 379 379
Lines 19778 19778
Branches 3016 3015 -1
=======================================
Hits 16993 16993
Misses 2785 2785 ☔ View full report in Codecov by Harness.
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Closes #1907.
rgbToHsl aliased its argument (let colorHsl = colorRgb) instead of copying it, then wrote the HSL result into that same array and returned it. Any caller that kept a reference to its RGB input had that array silently overwritten with the HSL output (input === result was true).
Fixes the alias to a copy ([...colorRgb]), per the fix suggested in the issue, and adds a regression test asserting the input array is left unchanged after conversion.
The existing HSL conversion math is untouched — only the in-place mutation is fixed.