mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 04:14:52 +08:00
fixed set fill attr bug which occurred when instantiating the fill with a string color and then setting it later to a fill object such as a gradient or pattern. The fix will apply to any attr which can be a string or object
This commit is contained in:
@@ -144,7 +144,8 @@ Kinetic.GlobalObject = {
|
||||
//return Object.prototype.toString.call(obj) == '[object Array]';
|
||||
},
|
||||
_isObject: function(obj) {
|
||||
return obj === Object(obj);
|
||||
return ( typeof obj == 'object');
|
||||
//return obj === Object(obj);
|
||||
},
|
||||
_isNumber: function(obj) {
|
||||
return Object.prototype.toString.call(obj) == '[object Number]';
|
||||
|
@@ -183,9 +183,16 @@ Kinetic.Node.prototype = {
|
||||
* to the node and then traverse
|
||||
*/
|
||||
if(go._isObject(val) && !go._isArray(val) && !go._isElement(val) && !go._hasMethods(val)) {
|
||||
if(obj[key] === undefined) {
|
||||
/*
|
||||
* since some properties can be strings or objects, e.g.
|
||||
* fill, we need to first check that obj is an object
|
||||
* before setting properties. If it's not an object,
|
||||
* overwrite obj with an object literal
|
||||
*/
|
||||
if(!Kinetic.GlobalObject._isObject(obj[key])) {
|
||||
obj[key] = {};
|
||||
}
|
||||
|
||||
setAttrs(obj[key], val, level + 1);
|
||||
}
|
||||
/*
|
||||
|
@@ -104,6 +104,7 @@ Kinetic.Shape.prototype = {
|
||||
context.save();
|
||||
|
||||
var fill = this.attrs.fill;
|
||||
|
||||
if(!!fill) {
|
||||
if(!this.appliedShadow) {
|
||||
appliedShadow = this._applyShadow();
|
||||
|
Reference in New Issue
Block a user