Skip to content

Commit

Permalink
Fix Circle toSVG method adding an incorrect double quote (#5085)
Browse files Browse the repository at this point in the history
* Fix Circle toSVG method adding an incorrect double quote

* Add tests for Circle.toSVG
  • Loading branch information
nmorel authored and asturur committed Jul 12, 2018
1 parent 7c7c227 commit efa490f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/shapes/circle.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
'" transform="', this.getSvgTransform(),
' ', this.getSvgTransformMatrix(), '"',
this.addPaintOrder(),
'"/>\n'
'/>\n'
);
}

Expand Down
14 changes: 14 additions & 0 deletions test/unit/circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@
assert.deepEqual(circle.toObject(), augmentedProperties);
});

QUnit.test('toSVG with full circle', function(assert) {
var circle = new fabric.Circle({ width: 100, height: 100, radius: 10 });
var svg = circle.toSVG();

assert.equal(svg, '<circle cx="0" cy="0" r="10" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;" transform="translate(10.5 10.5) "/>\n');
});

QUnit.test('toSVG with half circle', function(assert) {
var circle = new fabric.Circle({ width: 100, height: 100, radius: 10, endAngle: Math.PI });
var svg = circle.toSVG();

assert.equal(svg, '<path d="M 10 0 A 10 10 0 0 1 -10 0" style="stroke: none; stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;" transform="translate(10.5 10.5) "/>\n');
});

QUnit.test('fromElement', function(assert) {
assert.ok(typeof fabric.Circle.fromElement === 'function');

Expand Down

0 comments on commit efa490f

Please sign in to comment.