浏览代码

Merge pull request #2933 from csachs/hasDarkBackgroundNamedColor

Use computed background style if colorToRgb fails (fixes #2635)
Hakim El Hattab 4 年之前
父节点
当前提交
444d127053
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      js/controllers/backgrounds.js

+ 2 - 2
js/controllers/backgrounds.js

@@ -192,8 +192,8 @@ export default class Backgrounds {
 		// color, no class will be added
 		// color, no class will be added
 		let contrastColor = data.backgroundColor;
 		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 );
 			let computedBackgroundStyle = window.getComputedStyle( element );
 			if( computedBackgroundStyle && computedBackgroundStyle.backgroundColor ) {
 			if( computedBackgroundStyle && computedBackgroundStyle.backgroundColor ) {
 				contrastColor = computedBackgroundStyle.backgroundColor;
 				contrastColor = computedBackgroundStyle.backgroundColor;