Skip to content

Commit

Permalink
fix reload from json (#3691)
Browse files Browse the repository at this point in the history
* fix reload from json

* fix just on path
  • Loading branch information
asturur authored Feb 14, 2017
1 parent 7ff1063 commit 5cd1111
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/shapes/path.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,9 @@
*/
toObject: function(propertiesToInclude) {
var o = extend(this.callSuper('toObject', ['sourcePath', 'pathOffset'].concat(propertiesToInclude)), {
path: this.path.map(function(item) { return item.slice(); })
path: this.path.map(function(item) { return item.slice(); }),
top: this.top,
left: this.left,
});
return o;
},
Expand Down
1 change: 0 additions & 1 deletion test/unit/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,6 @@
deepEqual(augmentedObjectRepr.transformMatrix, toObjectObj.transformMatrix);
notEqual(augmentedObjectRepr.strokeDashArray, toObjectObj.strokeDashArray);
deepEqual(augmentedObjectRepr.strokeDashArray, toObjectObj.strokeDashArray);

});

test('toDatalessObject', function() {
Expand Down
14 changes: 13 additions & 1 deletion test/unit/path.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,21 @@
});
});

asyncTest('toObject', function() {
makePathObject(function(path) {
path.top = fabric.Object.prototype.top;
path.left = fabric.Object.prototype.left;
path.includeDefaultValues = false;
var obj = path.toObject();
equal(obj.top, fabric.Object.prototype.top, 'top is available also when equal to prototype');
equal(obj.left, fabric.Object.prototype.left, 'left is available also when equal to prototype');
start();
});
});

asyncTest('toSVG', function() {
makePathObject(function(path) {
ok(typeof path.toObject == 'function');
ok(typeof path.toSVG == 'function');
deepEqual(path.toSVG(), '<path d="M 100 100 L 300 100 L 200 300 z" style="stroke: rgb(0,0,255); stroke-width: 1; stroke-dasharray: none; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(255,0,0); fill-rule: nonzero; opacity: 1;" transform="translate(200.5 200.5) translate(-200, -200) " stroke-linecap="round" />\n');
start();
});
Expand Down

0 comments on commit 5cd1111

Please sign in to comment.