Skip to content

Commit

Permalink
Merge pull request #2933 from csachs/hasDarkBackgroundNamedColor
Browse files Browse the repository at this point in the history
Use computed background style if colorToRgb fails (fixes #2635)
  • Loading branch information
hakimel authored Apr 14, 2021
2 parents be110fa + d1f6e6c commit 444d127
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/controllers/backgrounds.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ export default class Backgrounds {
// color, no class will be added
let contrastColor = data.backgroundColor;

// If no bg color was found, check the computed background
if( !contrastColor ) {
// If no bg color was found, or it cannot be converted by colorToRgb, check the computed background
if( !contrastColor || !colorToRgb( contrastColor ) ) {
let computedBackgroundStyle = window.getComputedStyle( element );
if( computedBackgroundStyle && computedBackgroundStyle.backgroundColor ) {
contrastColor = computedBackgroundStyle.backgroundColor;
Expand Down

0 comments on commit 444d127

Please sign in to comment.