Merge pull request #2568 from asturur/fix-shadow

Update shadow.class.js
This commit is contained in:
Juriy Zaytsev 2015-11-13 11:04:51 +01:00
commit ae1ee007a3
2 changed files with 17 additions and 13 deletions

View file

@ -146,22 +146,18 @@
color: this.color,
blur: this.blur,
offsetX: this.offsetX,
offsetY: this.offsetY
offsetY: this.offsetY,
affectStroke: this.affectStroke
};
}
var obj = { }, proto = fabric.Shadow.prototype;
if (this.color !== proto.color) {
obj.color = this.color;
}
if (this.blur !== proto.blur) {
obj.blur = this.blur;
}
if (this.offsetX !== proto.offsetX) {
obj.offsetX = this.offsetX;
}
if (this.offsetY !== proto.offsetY) {
obj.offsetY = this.offsetY;
}
['color', 'blur', 'offsetX', 'offsetY', 'affectStroke'].forEach(function(prop) {
if (this[prop] !== proto[prop]) {
obj[prop] = this[prop];
}
}, this);
return obj;
}
});

View file

@ -135,6 +135,14 @@
equal(JSON.stringify(object), '{"color":"rgb(0,0,0)","blur":0,"offsetX":0,"offsetY":0}');
});
test('clone with affectStroke', function() {
var shadow = new fabric.Shadow({affectStroke: true, blur: 5});
ok(typeof shadow.toObject == 'function');
var object = shadow.toObject(),
shadow2 = new fabric.Shadow(object);
deepEqual(shadow, shadow2);
});
test('toObject without default value', function() {
var shadow = new fabric.Shadow();
shadow.includeDefaultValues = false;