Skip to content

Fix luminance with non-integer Sass color channels#42453

Open
cyphercodes wants to merge 1 commit into
twbs:mainfrom
cyphercodes:fix-luminance-non-integer-channels
Open

Fix luminance with non-integer Sass color channels#42453
cyphercodes wants to merge 1 commit into
twbs:mainfrom
cyphercodes:fix-luminance-non-integer-channels

Conversation

@cyphercodes
Copy link
Copy Markdown

Description

Rounds and clamps Sass RGB channel values before using them as indexes into the precomputed luminance lookup table.

Motivation & Context

Fixes #42447. Sass color operations can produce fractional channel values; using those values directly as nth() indexes can raise an invalid index error.

Type of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (non-breaking change)
  • Breaking change (fix or feature that would change existing functionality)

Checklist

  • I have read the contributing guidelines
  • My code follows the code style of the project (using npm run lint)
  • My change introduces changes to the documentation
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • All new and existing tests passed

Live previews

Related issues

Fixes #42447

Verification

  • npm run css-test
  • npm run css-lint
  • npm run lint (passes with existing TODO/FIXME warnings)
  • npx stylelint scss/_functions.scss scss/tests/functions/_luminance.test.scss --cache --cache-location .cache/.stylelintcache
  • git diff --check

@cyphercodes cyphercodes requested a review from a team as a code owner June 1, 2026 03:21
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.

luminance() crashes with 'Invalid index' when Sass color functions return non-integer channel values

1 participant