Skip to content
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

Use css-color module #3675

Closed
wants to merge 4 commits into from
Closed

Use css-color module #3675

wants to merge 4 commits into from

Conversation

asamuzaK
Copy link
Contributor

Fix #3657

Benchmark result

Benchmark main patch
# dom/get-computed-style/getComputedStyle() on document.body # jsdom x 24,411 ops/sec ±2.90% (88 runs sampled) jsdom x 28,467 ops/sec ±1.05% (89 runs sampled)
# dom/get-computed-style/getComputedStyle() on element with non-rgb color # jsdom x 24,564 ops/sec ±1.24% (89 runs sampled) jsdom x 29,178 ops/sec ±0.91% (91 runs sampled)
# dom/get-computed-style/getComputedStyle() on element with rgb color # jsdom x 14,097 ops/sec ±4.15% (85 runs sampled) jsdom x 13,822 ops/sec ±2.08% (84 runs sampled)

Ignore the 2nd getComputedStyle() on element with non-rgb color as it simply failed.
It looks like jsdom does not pass unsupported colors, e.g. color-mix(), correctly to getSpecifiedColor().
We need to fix https://github.com/jsdom/jsdom/blob/main/lib/jsdom/living/helpers/style-rules.js#L175 to support them?

# dom/get-computed-style/getComputedStyle() on document.body #
jsdom  x 24,411 ops/sec ±2.90% (88 runs sampled)

# dom/get-computed-style/getComputedStyle() on element with non-rgb color #
jsdom  x 24,564 ops/sec ±1.24% (89 runs sampled)

# dom/get-computed-style/getComputedStyle() on element with rgb color #
jsdom  x 14,097 ops/sec ±4.15% (85 runs sampled)
# dom/get-computed-style/getComputedStyle() on document.body #
jsdom  x 28,467 ops/sec ±1.05% (89 runs sampled)

# dom/get-computed-style/getComputedStyle() on element with non-rgb color #
jsdom  x 29,178 ops/sec ±0.91% (91 runs sampled)

# dom/get-computed-style/getComputedStyle() on element with rgb color #
jsdom  x 13,822 ops/sec ±2.08% (84 runs sampled)
@asamuzaK
Copy link
Contributor Author

We need to fix https://github.com/jsdom/jsdom/blob/main/lib/jsdom/living/helpers/style-rules.js#L175 to support them?

I found out that cssstyle only supports hex, rgb and hsl.
https://github.com/jsdom/cssstyle/blob/main/lib/parsers.js#L289
I think that css-color may also be useful for cssstyle.

@asamuzaK
Copy link
Contributor Author

asamuzaK commented Jan 28, 2024

We need to fix https://github.com/jsdom/jsdom/blob/main/lib/jsdom/living/helpers/style-rules.js#L175 to support them?

I found out that cssstyle only supports hex, rgb and hsl. https://github.com/jsdom/cssstyle/blob/main/lib/parsers.js#L289 I think that css-color may also be useful for cssstyle.

Filed a PR on cssstyle Extend CSS color support with css-color module

@asamuzaK asamuzaK closed this Feb 24, 2024
@asamuzaK asamuzaK deleted the css-color branch February 24, 2024 02:22
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.

Improve support for CSS colors
1 participant