Skip to content

fix: hsl and rgb with alpha channel parsed incorrectly #5

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

bpajor
Copy link

@bpajor bpajor commented Feb 7, 2025

Description

The original reason of this change is an error with message: Uninitialized string offset 3.

The syntax that was causing the error was:

background-color: hsl(0 0% 10% / calc(1 - var(--hover, 0) * 0.25));

that is being used in many clients css.

The problem was that we were not correctly indexing the content of the function, so that calc was unreachable and was causing the error.

Hovewer fixing the issue has showed in result, that we were not unable to correctly parse the hsl or rgb functions with alpha channel (after /). They were translated to the same functions but with 4 arguments which is incorrect.

With that PR we can fix that problem by discovering when we have hsl or rgb with alpha channel and convert it to hsla or rgba functions, which can take 4 arguments (with alpha channel).

Usage of / is explained here:

Testing

Unit tests are extended to cover the change, checking the hsl and rgb with an alpha channel.

@bpajor bpajor force-pushed the bug_fix_converting_hsl_rgb_with_aplha_channell branch from 5a82772 to 38dcef8 Compare February 7, 2025 09:31
@bpajor bpajor marked this pull request as ready for review February 7, 2025 09:31
@bpajor bpajor merged commit e4ca39e into patched-2024 Mar 3, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants