diff --git a/bi/core.js b/bi/core.js index 8cb222b3d..74a546c95 100644 --- a/bi/core.js +++ b/bi/core.js @@ -16822,7 +16822,7 @@ BI.extend(BI.DOM, { }, isColor: function (color) { - return this.isRGBColor(color) || this.isHexColor(color); + return color && (this.isRGBColor(color) || this.isHexColor(color)); }, isRGBColor: function (color) { @@ -16853,7 +16853,7 @@ BI.extend(BI.DOM, { //获取对比颜色 getContrastColor: function (color) { - if (!color) { + if (!color || !this.isColor(color)) { return ""; } if (this.isDarkColor(color)) { diff --git a/docs/core.js b/docs/core.js index 0c3403acc..43424df7d 100644 --- a/docs/core.js +++ b/docs/core.js @@ -22840,7 +22840,7 @@ BI.extend(BI.DOM, { }, isColor: function (color) { - return this.isRGBColor(color) || this.isHexColor(color); + return color && (this.isRGBColor(color) || this.isHexColor(color)); }, isRGBColor: function (color) { @@ -22871,7 +22871,7 @@ BI.extend(BI.DOM, { //获取对比颜色 getContrastColor: function (color) { - if (!color) { + if (!color || !this.isColor(color)) { return ""; } if (this.isDarkColor(color)) { diff --git a/src/core/func/function.js b/src/core/func/function.js index b26cb99df..5cb7acfab 100644 --- a/src/core/func/function.js +++ b/src/core/func/function.js @@ -104,7 +104,7 @@ BI.extend(BI.DOM, { }, isColor: function (color) { - return this.isRGBColor(color) || this.isHexColor(color); + return color && (this.isRGBColor(color) || this.isHexColor(color)); }, isRGBColor: function (color) { @@ -135,7 +135,7 @@ BI.extend(BI.DOM, { //获取对比颜色 getContrastColor: function (color) { - if (!color) { + if (!color || !this.isColor(color)) { return ""; } if (this.isDarkColor(color)) {