diff --git a/src/shapes/object.class.js b/src/shapes/object.class.js index a12df6e9183..ba245627606 100644 --- a/src/shapes/object.class.js +++ b/src/shapes/object.class.js @@ -1375,7 +1375,7 @@ * @param {Function} alternative function to call if browser does not support lineDash */ _setLineDash: function(ctx, dashArray, alternative) { - if (!dashArray) { + if (!dashArray || dashArray.length === 0) { return; } // Spec requires the concatenation of two copies the dash list when the number of elements is odd diff --git a/test/unit/object.js b/test/unit/object.js index af8b48038a0..6d24fa0de7b 100644 --- a/test/unit/object.js +++ b/test/unit/object.js @@ -531,6 +531,10 @@ assert.equal(object.strokeDashArray.length, 3, 'strokeDash array is odd'); object._setLineDash(canvas.contextContainer, object.strokeDashArray, null); assert.equal(object.strokeDashArray.length, 6, 'strokeDash array now is even'); + + assert.equal(canvas.contextContainer.getLineDash().length, 6, 'object pushed line dash to canvas'); + object._setLineDash(canvas.contextContainer, [], null); + assert.equal(canvas.contextContainer.getLineDash().length, 6, 'bailed immediately as array empty'); }); QUnit.test('straighten', function(assert) {