Repository navigation
Core: Allow fractional channel values in rgb() and rgba() - #195
Open
RaphaelFakhri wants to merge 1 commit into
Open
RaphaelFakhri wants to merge 1 commit into
RaphaelFakhri wants to merge 1 commit into
Conversation
CSS Color Module Level 4 allows numbers, not only integers, for the red, green and blue arguments of rgb() and rgba(), and browsers may return values such as "rgb(2.5, 3.4, 4.6)" from getComputedStyle(). The rgb parser only accepted integers, so these strings fell back to the default color (white), and animations started from or ended at white. Accept an optional fractional part in each channel. The value is then floored like the percentage form, so "rgb(127.5, 0, 0)" parses the same as "rgb(50%, 0%, 0%)".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CSS Color Module Level 4 allows numbers, not only integers, for the red, green, and blue arguments of
rgb()andrgba(), and browsers may return values such asrgb(2.5, 3.4, 4.6)fromgetComputedStyle()(see the web-platform-tests casecss/css-color/parsing/color-computed-rgb.html). The integerrgb()parser accepted only whole numbers, so these strings fell back to the default color, and animations started from or ended at white.This change accepts an optional fractional part in each channel. The value is then floored like the percentage form, so
rgb(127.5, 0, 0)parses the same asrgb(50%, 0%, 0%).Before:
After:
The two new parse tests fail without the source change:
npm run test:chromepasses for all jQuery versions injtr.yml.Fixes #194