Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

object._setLineDash tweak #6000

Merged
merged 1 commit into from
Nov 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/shapes/object.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,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
Expand Down
4 changes: 4 additions & 0 deletions test/unit/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down