diff --git a/CHANGELOG.md b/CHANGELOG.md index 734797a0..3b6d38a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,7 @@ solid fixes, as we are paving the way for the upcoming release of `1.0.0`. Here - Draw shadows on `Raster` images (#1437) - Fix boolean operation edge case (#1506, #1513, #1515). - Remove memory leak on gradient colors (#1499). -- Support alpha channel in CSS colors (#1468, #1539). +- Support alpha channel in CSS colors (#1468, #1539, #1565). - Improve color CSS string parsing and documentation. - Improve caching of item positions (#1503). - Always draw selected position in global coordinates system (#1545). diff --git a/src/style/Color.js b/src/style/Color.js index a836049c..05f4691f 100644 --- a/src/style/Color.js +++ b/src/style/Color.js @@ -64,7 +64,7 @@ var Color = Base.extend(new function() { var match = string.match( /^#([\da-f]{2})([\da-f]{2})([\da-f]{2})([\da-f]{2})?$/i ) || string.match( - /^#([\da-f])([\da-f])([\da-f])$/i + /^#([\da-f])([\da-f])([\da-f])([\da-f])?$/i ), type = 'rgb', components; diff --git a/test/tests/Color.js b/test/tests/Color.js index 968bfa8d..32f0cf9d 100644 --- a/test/tests/Color.js +++ b/test/tests/Color.js @@ -69,8 +69,11 @@ test('Creating Colors', function() { equals(new Color('#FF3300'), new Color(1, 0.2, 0), 'Color from uppercase hex string'); + equals(new Color('#f009'), new Color(1, 0, 0, .6), + 'Color from 4 characters hex code with alpha'); + equals(new Color('#ff000099'), new Color(1, 0, 0, .6), - 'Color from hex code with alpha'); + 'Color from 8 characters hex code with alpha'); equals(new Color('rgb(255, 0, 0)'), new Color(1, 0, 0), 'Color from rgb() string');