Skip to content

Commit 34ad904

Browse files
committed
Fix wrong default fillColor on TextItems.
1 parent cb0dcf1 commit 34ad904

2 files changed

Lines changed: 16 additions & 11 deletions

File tree

src/item/Item.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
7272
else
7373
this._setProject(project);
7474
}
75-
this._style = new Style(this._project._currentStyle);
76-
this._style._item = this;
75+
this._style = new Style(this._project._currentStyle, this);
7776
this._matrix = new Matrix();
7877
if (point)
7978
this._matrix.translate(point);
@@ -382,7 +381,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
382381
},
383382

384383
setStyle: function(style) {
385-
this._style.initialize(style);
384+
this._style.set(style);
386385
},
387386

388387
hasFill: function() {

src/style/Style.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,23 @@ var Style = Base.extend(new function() {
202202
Item.inject(item);
203203
return fields;
204204
}, /** @lends Style# */{
205-
initialize: function Style(style) {
205+
initialize: function Style(style, _item) {
206206
// We keep values in a separate object that we can iterate over.
207207
this._values = {};
208-
if (this._item instanceof TextItem)
208+
this._item = _item;
209+
if (_item instanceof TextItem)
209210
this._defaults = this._textDefaults;
210-
if (style) {
211-
// If the passed style object is also a Style, clone its clonable
212-
// fields rather than simply copying them.
213-
var isStyle = style instanceof Style,
214-
// Use the other stlyle's _values object for iteration
215-
values = isStyle ? style._values : style;
211+
if (style)
212+
this.set(style);
213+
},
214+
215+
set: function(style) {
216+
// If the passed style object is also a Style, clone its clonable
217+
// fields rather than simply copying them.
218+
var isStyle = style instanceof Style,
219+
// Use the other stlyle's _values object for iteration
220+
values = isStyle ? style._values : style;
221+
if (values) {
216222
for (var key in values) {
217223
if (key in this._defaults) {
218224
var value = values[key];

0 commit comments

Comments
 (0)