Implement calling of _removeOwner() for gradients.

This commit is contained in:
Jürg Lehni 2013-04-09 08:36:02 -07:00
parent 9b50020721
commit bf21e32082
2 changed files with 9 additions and 5 deletions

View file

@ -225,8 +225,13 @@ var Color = this.Color = Base.extend(new function() {
// name combination.
parser = parsers[type][index] = name === 'gradient'
? function(value) {
if (value)
value._addOwner(this);
var current = this._components[0];
if (current !== value) {
if (current)
current._removeOwner(this);
if (value)
value._addOwner(this);
}
return value;
}
: name === 'hue'

View file

@ -45,7 +45,7 @@ var Gradient = this.Gradient = Base.extend(/** @lends Gradient# */{
},
/**
* Called by GradientColor#initialize
* Called by Color#setGradient()
* This is required to pass on _changed() notifications to the _owners.
*/
_addOwner: function(color) {
@ -54,9 +54,8 @@ var Gradient = this.Gradient = Base.extend(/** @lends Gradient# */{
this._owners.push(color);
},
// TODO: Where and when should this be called:
/**
* Called by GradientColor whenever this gradient stops being used.
* Called by Color whenever this gradient stops being used.
*/
_removeOwner: function(color) {
var index = this._owners ? this._owners.indexOf(color) : -1;