modified setDefaultAttrs() so that it doesn't overwrite attrs defaulted in a custom class that extends a Kinetic class

This commit is contained in:
Eric Rowell 2012-05-12 15:15:42 -07:00
parent 28f7fc246d
commit 1146919d3d
4 changed files with 28 additions and 12 deletions

14
dist/kinetic-core.js vendored
View File

@ -3,7 +3,7 @@
* http://www.kineticjs.com/
* Copyright 2012, Eric Rowell
* Licensed under the MIT or GPL Version 2 licenses.
* Date: May 09 2012
* Date: May 12 2012
*
* Copyright (C) 2011 - 2012 by Eric Rowell
*
@ -308,10 +308,18 @@ Kinetic.Node.prototype = {
if(config) {
for(var key in config) {
var val = config[key];
/*
* only set the attr if it's undefined in case
* a developer writes a custom class that extends
* a Kinetic Class such that their default property
* isn't overwritten by the Kinetic Class default
* property
*/
if(this.attrs[key] === undefined) {
this.attrs[key] = config[key];
}
}
}
},
/**
* set attrs
@ -1496,7 +1504,7 @@ Kinetic.Stage.prototype = {
this._setDefaults();
// reset node attrs
this.setDefaultAttrs({
this.setAttrs({
visible: true,
listening: true,
name: undefined,

File diff suppressed because one or more lines are too long

View File

@ -124,10 +124,18 @@ Kinetic.Node.prototype = {
if(config) {
for(var key in config) {
var val = config[key];
/*
* only set the attr if it's undefined in case
* a developer writes a custom class that extends
* a Kinetic Class such that their default property
* isn't overwritten by the Kinetic Class default
* property
*/
if(this.attrs[key] === undefined) {
this.attrs[key] = config[key];
}
}
}
},
/**
* set attrs

View File

@ -213,7 +213,7 @@ Kinetic.Stage.prototype = {
this._setDefaults();
// reset node attrs
this.setDefaultAttrs({
this.setAttrs({
visible: true,
listening: true,
name: undefined,