diff --git a/Source/Core/Color.js b/Source/Core/Color.js index 440016b3b8a2..f682afc032ec 100644 --- a/Source/Core/Color.js +++ b/Source/Core/Color.js @@ -2024,5 +2024,14 @@ define([ */ Color.YELLOWGREEN = freezeObject(Color.fromCssColorString('#9ACD32')); + /** + * An immutable Color instance initialized to CSS transparent. + * + * + * @constant + * @type {Color} + */ + Color.TRANSPARENT = freezeObject(new Color(0, 0, 0, 0)); + return Color; }); diff --git a/Source/Widgets/InfoBox/InfoBox.js b/Source/Widgets/InfoBox/InfoBox.js index a023932ed828..f428a4749331 100644 --- a/Source/Widgets/InfoBox/InfoBox.js +++ b/Source/Widgets/InfoBox/InfoBox.js @@ -123,8 +123,9 @@ click: function () { closeClicked.raiseEvent(this); }'); if (firstElementChild !== null && frameContent.childNodes.length === 1) { var style = window.getComputedStyle(firstElementChild); if (style !== null) { - var color = Color.fromCssColorString(style['background-color']); - if (color.alpha !== 0) { + var backgroundColor = style['background-color']; + var color = Color.fromCssColorString(backgroundColor); + if (defined(color) && color.alpha !== 0) { background = style['background-color']; } } diff --git a/Specs/Core/ColorSpec.js b/Specs/Core/ColorSpec.js index 9d586c218e7b..daa928bb5f32 100644 --- a/Specs/Core/ColorSpec.js +++ b/Specs/Core/ColorSpec.js @@ -161,6 +161,10 @@ defineSuite([ expect(new Color(0.1, 0.2, 0.3, 0.4).toCssColorString()).toEqual('rgba(25,51,76,0.4)'); }); + it('fromCssColorString supports transparent', function() { + expect(Color.fromCssColorString('transparent')).toEqual(new Color(0.0, 0.0, 0.0, 0.0)); + }); + it('fromCssColorString supports the #rgb format', function() { expect(Color.fromCssColorString('#369')).toEqual(new Color(0.2, 0.4, 0.6, 1.0)); }); diff --git a/Specs/Widgets/InfoBox/InfoBoxSpec.js b/Specs/Widgets/InfoBox/InfoBoxSpec.js index 21d80e16f777..a13103f36562 100644 --- a/Specs/Widgets/InfoBox/InfoBoxSpec.js +++ b/Specs/Widgets/InfoBox/InfoBoxSpec.js @@ -53,7 +53,7 @@ defineSuite([ }); runs(function() { - infoBox.viewModel.description = '