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 computed background style if colorToRgb fails (fixes #2635) #2933

Merged
merged 1 commit into from
Apr 14, 2021

Conversation

csachs
Copy link
Contributor

@csachs csachs commented Apr 11, 2021

The has-dark-background class is not properly added, if a named color (e.g. black) is used for the data-background-color attribute.

If the attribute is explicitly set, it will be passed to colorToRgb() which can only handle explicit rgb notations, not named colors.

As a simple workaround, this PR tries the conversion beforehand, and will use the computed styles if it fails.

Alternatively, one could expand colorToRgb() to support named colors, e.g. by querying the browser via a canvas (c.f. https://stackoverflow.com/a/47355187 ).

@hakimel hakimel merged commit 444d127 into hakimel:dev Apr 14, 2021
@hakimel
Copy link
Owner

hakimel commented Apr 14, 2021

Good catch. Thanks for the fix!

R0bes pushed a commit to R0bes/Terraform-Presentation that referenced this pull request Jun 7, 2021
Use computed background style if colorToRgb fails (fixes hakimel#2635)
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.

2 participants