Fix wrong default fillColor on TextItems.

This commit is contained in:
Jürg Lehni 2013-06-12 17:30:35 -07:00
parent cb0dcf1719
commit 34ad9045cc
2 changed files with 16 additions and 11 deletions

View file

@ -72,8 +72,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
else
this._setProject(project);
}
this._style = new Style(this._project._currentStyle);
this._style._item = this;
this._style = new Style(this._project._currentStyle, this);
this._matrix = new Matrix();
if (point)
this._matrix.translate(point);
@ -382,7 +381,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
},
setStyle: function(style) {
this._style.initialize(style);
this._style.set(style);
},
hasFill: function() {

View file

@ -202,17 +202,23 @@ var Style = Base.extend(new function() {
Item.inject(item);
return fields;
}, /** @lends Style# */{
initialize: function Style(style) {
initialize: function Style(style, _item) {
// We keep values in a separate object that we can iterate over.
this._values = {};
if (this._item instanceof TextItem)
this._item = _item;
if (_item instanceof TextItem)
this._defaults = this._textDefaults;
if (style) {
// If the passed style object is also a Style, clone its clonable
// fields rather than simply copying them.
var isStyle = style instanceof Style,
// Use the other stlyle's _values object for iteration
values = isStyle ? style._values : style;
if (style)
this.set(style);
},
set: function(style) {
// If the passed style object is also a Style, clone its clonable
// fields rather than simply copying them.
var isStyle = style instanceof Style,
// Use the other stlyle's _values object for iteration
values = isStyle ? style._values : style;
if (values) {
for (var key in values) {
if (key in this._defaults) {
var value = values[key];