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 #3674

Closed
wants to merge 12 commits into from
Closed

Use css-color module #3674

wants to merge 12 commits into from

Conversation

asamuzaK
Copy link
Contributor

@asamuzaK asamuzaK commented Jan 27, 2024

Fix #3657

Benchmark result

Benchmark main patch
# dom/get-computed-style/getComputedStyle() on document.body # jsdom x 24,373 ops/sec ±2.94% (95 runs sampled) jsdom x 29,307 ops/sec ±0.72% (90 runs sampled)
# dom/get-computed-style/getComputedStyle() on element with rgb color # jsdom x 13,206 ops/sec ±4.41% (86 runs sampled) jsdom x 13,911 ops/sec ±1.81% (87 runs sampled)
# dom/get-computed-style/getComputedStyle() on element with non-rgb color # jsdom x 24,526 ops/sec ±1.32% (93 runs sampled) jsdom x 29,089 ops/sec ±0.97% (90 runs sampled)

The last getComputedStyle() on element with non-rgb color benchmark is simply failing, so ignore it.
It looks like jsdom does not pass non-rgb 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 #
jsdom  x 24,796 ops/sec ±2.27% (92 runs sampled)
# dom/get-computed-style/getComputedStyle #
jsdom  x 13,315 ops/sec ±2.00% (88 runs sampled)
# dom/get-computed-style/getComputedStyle #
jsdom  x 8,834 ops/sec ±4.68% (88 runs sampled)
@asamuzaK asamuzaK marked this pull request as draft January 27, 2024 00:44
Otherwise, if a new syntax such as 'rgb(128 128 128 / 0.5)' is passed, the value will be returned as is.
@asamuzaK asamuzaK changed the title Use css-color module if color is neither hex nor rgb Use css-color module Jan 27, 2024
@asamuzaK
Copy link
Contributor Author

The commit log is a mess, so I'll close it and submit a new PR.

@asamuzaK asamuzaK closed this Jan 27, 2024
@asamuzaK asamuzaK deleted the color branch February 2, 2024 05:44
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