mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-28 17:02:24 -05:00
Fix exported SVG missing viewBox attribute (#1576)
SVG viewBox attribute was not added when bounds rectangle point was 0,0.
This commit is contained in:
parent
314390d789
commit
de824e1846
2 changed files with 7 additions and 1 deletions
|
@ -427,7 +427,7 @@ new function() {
|
|||
if (rect) {
|
||||
attrs.width = rect.width;
|
||||
attrs.height = rect.height;
|
||||
if (rect.x || rect.y)
|
||||
if (rect.x || rect.x === 0 || rect.y || rect.y === 0)
|
||||
attrs.viewBox = formatter.rectangle(rect);
|
||||
}
|
||||
var node = SvgElement.create('svg', attrs, formatter),
|
||||
|
|
|
@ -113,6 +113,12 @@ test('Export SVG path at precision 0', function() {
|
|||
equals(path.exportSVG({ precision: 0 }).getAttribute('d'), 'M0,2l1,1');
|
||||
});
|
||||
|
||||
test('Export SVG viewbox attribute with top left at origin', function() {
|
||||
var path = new Path.Rectangle(new Point(10, 10), new Size(80));
|
||||
var rectangle = new Rectangle(new Point(0, 0), new Size(100));
|
||||
equals(project.exportSVG({ bounds: rectangle }).getAttribute('viewBox'), '0,0,100,100');
|
||||
});
|
||||
|
||||
if (!isNode) {
|
||||
// JSDom does not have SVG rendering, so we can't test there.
|
||||
test('Export transformed shapes', function(assert) {
|
||||
|
|
Loading…
Reference in a new issue