-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Improve support for CSS colors #3657
Comments
That would be great! The hardest part seems like figuring out the right integration points. Do you think it will be easy to slot into jsdom's Ultimately, we want to have jsdom code match the spec as much as possible. Although I find that with CSS specs that is not very easy. I guess the question is, which parts of https://drafts.csswg.org/css-color-4/#resolving-color-values should be handled by jsdom, and which parts by your module? And what will the interface look like? Currently the code that tries to implement that section is jsdom/lib/jsdom/living/helpers/style-rules.js Lines 213 to 229 in cf8b707
|
I am planning to add a new function to the module something like: export const getColorInComputedStyle = (color, option = {}) => {
let computedStyle;
// convert given `color` to `rgb(r, g, b)` / `rgba(r, g, b, a)`
return computedStyle;
}; |
I think that will mostly work. Two minor notes:
|
Thanks!
|
Published on npm @asamuzakjp/css-color |
Basic info:
Minimal reproduction case
How does similar code behave in browsers?
'rgb(0, 128, 0)' is returned as expected.
Proposal
I took a look at jsdom/lib/jsdom/living/helpers/colors.js and found that CSS color support of jsdom is quite limited.
In another project of mine, I am using an internal module that can parse / convert colors defined in CSS Color Module Level 4.
sidebarTabs/src/mjs/color.js
If you are interested in using it with jsdom, I will publish it as a public module on npm.
How about that?
The text was updated successfully, but these errors were encountered: