Skip to content

Accept #rgba and #rrggbbaa notation #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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

IvanSanchez
Copy link

Add parsing for the #rgba and #rrggbbaa notations.

These notations are specified in the CSS Color Module Level 4 specs (https://drafts.csswg.org/css-color/#hex-notation) , and supported by current browsers as per Chrome 52 https://www.chromestatus.com/feature/5685348285808640 , Firefox 49 https://bugzilla.mozilla.org/show_bug.cgi?id=567283 and Safari 9.1.

I added some spaces and leading zeroes around, just to improve the readability a bit and to make better sense of the bit-wise logic. I can remove those if you ask.

@IvanSanchez
Copy link
Author

IvanSanchez commented Feb 21, 2017

Wait, somehow JS assumes complement-2 signed integers, so this code fails for #rrggbbaa values where rr >= 80. Added 0-255 coercion (& 0xff) to the rr byte to avoid troubles with complement-2 negative numbers.

@deanm
Copy link
Owner

deanm commented Feb 21, 2017

I wrote a patch to support this, but I want to comment on the statement "and supported by current browsers as per Chrome 52". It is in fact not launched, see for example:

https://bugs.chromium.org/p/chromium/issues/detail?id=76362#c46

Trying a 4 digit test case in Chrome does not work on a current 56.0.2924.87, for example:

http://test.csswg.org/suites/css-color-4_dev/nightly-unstable/html/hex-004.htm

So while I have the patch sitting around for it, it seems this is in fact still a draft proposal, has possible compatibility problems, and is not standard yet. That doesn't mean I am against supporting it now or in the future, it's just not common place yet... Is there a good argument for adding it right now?

@IvanSanchez
Copy link
Author

Hah, I had some of the experimental flags set in my chrome, so I didn't notice that.

So far this is breaking one of my use cases (one that can be worked around by changing some backend data). I guess this doesn't count as a good argument for merging now, so this can wait.

@thth
Copy link

thth commented Nov 21, 2020

#rgba and #rrggbbaa have been supported by default by Chrome since version 62, released 3 years ago now.

Every modern browser has supported this for a while.

Should be time to apply the patch 🙂

@radoslavirha
Copy link

Hi, any update? Thanks

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.

4 participants