From a59fab0409234b7b5d7fc6ce878642f49e4cab33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 5 May 2011 11:16:26 +0100 Subject: [PATCH] Only change style and notify item of change if it differs from current one. --- src/item/PathStyle.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/item/PathStyle.js b/src/item/PathStyle.js index 9004fe2f..07d93ecb 100644 --- a/src/item/PathStyle.js +++ b/src/item/PathStyle.js @@ -55,11 +55,19 @@ var PathStyle = this.PathStyle = Base.extend(new function() { fields[set] = function(value) { var children = this._item && this._item.children; + value = isColor ? Color.read(arguments) : value; if (children) { for (var i = 0, l = children.length; i < l; i++) children[i]._style[set](value); } else { - this['_' + key] = isColor ? Color.read(arguments) : value; + var old = this['_' + key]; + if (old != value && !(old && old.equals && old.equals(value))) { + this['_' + key] = value; + // TODO: Tell _item what exactly has changed. Maybe introduce + // ChangeFlags, e.g. STROKE, COLOR, FILL, GEOMETRY, etc? + if (this._item && this._item._changed) + this._item._changed(); + } } return this; };