diff --git a/src/item/Group.js b/src/item/Group.js index 44559140..81b85858 100644 --- a/src/item/Group.js +++ b/src/item/Group.js @@ -73,7 +73,7 @@ var Group = this.Group = Item.extend(/** @lends Group# */{ // Allow Group to have children and named children this._children = []; this._namedChildren = {}; - if (!this.setProperties(arg)) + if (!this._setProperties(arg)) this.addChildren(Array.isArray(arg) ? arg : arguments); }, diff --git a/src/item/Item.js b/src/item/Item.js index 7cbe2560..7854aba5 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -112,18 +112,27 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{ ); }, - // #setProperties is part of the mechanism for Item constructors which take + // #_setProperties is part of the mechanism for Item constructors which take // one object literal describing all the properties to be set on the created // instance. - setProperties: function(props) { + _setProperties: function(props) { if (Base.isObject(props)) { - for (var key in props) - if (props.hasOwnProperty(key)) - this[key] = props[key]; + this.set(props); return true; } }, + /** + * Sets all the properties of the passed object literal to their values on + * the item it is called on, and returns the item itself. + */ + set: function(props) { + for (var key in props) + if (props.hasOwnProperty(key)) + this[key] = props[key]; + return this; + }, + /** * Private notifier that is called whenever a change occurs in this item or * its sub-elements, such as Segments, Curves, PathStyles, etc. diff --git a/src/item/PlacedSymbol.js b/src/item/PlacedSymbol.js index a6086a6a..b3b6ef6e 100644 --- a/src/item/PlacedSymbol.js +++ b/src/item/PlacedSymbol.js @@ -67,7 +67,7 @@ var PlacedSymbol = this.PlacedSymbol = PlacedItem.extend(/** @lends PlacedSymbol this.base(arg1 !== undefined && Point.read(arguments, 1)); // If we can handle setting properties through object literal, we're all // set. Otherwise we need to set symbol. - if (!this.setProperties(arg0)) + if (!this._setProperties(arg0)) this.setSymbol(arg0 instanceof Symbol ? arg0 : new Symbol(arg0)); }, diff --git a/src/item/Raster.js b/src/item/Raster.js index b366c57c..882be52d 100644 --- a/src/item/Raster.js +++ b/src/item/Raster.js @@ -42,7 +42,7 @@ var Raster = this.Raster = PlacedItem.extend(/** @lends Raster# */{ this.base(arg1 !== undefined && Point.read(arguments, 1)); // If we can handle setting properties through object literal, we're all // set. Otherwise we need to check the type of arg0: - if (!this.setProperties(arg0)) { + if (!this._setProperties(arg0)) { if (arg0.getContext) { this.setCanvas(arg0); } else if (typeof arg0 === 'string') { diff --git a/src/path/Path.js b/src/path/Path.js index 1198d350..70ca682e 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -54,7 +54,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{ // If it is an array, it can also be a description of a point, so // check its first entry for object as well. // But first see if segments are directly passed at all. If not, try - // #setProperties(arg). + // _setProperties(arg). var segments = Array.isArray(arg) ? typeof arg[0] === 'object' ? arg @@ -64,7 +64,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{ : null; this.setSegments(segments || []); if (!segments) - this.setProperties(arg); + this._setProperties(arg); }, clone: function() { diff --git a/src/text/TextItem.js b/src/text/TextItem.js index 04136386..30428a81 100644 --- a/src/text/TextItem.js +++ b/src/text/TextItem.js @@ -49,7 +49,7 @@ var TextItem = this.TextItem = Item.extend(/** @lends TextItem# */{ this._content = ''; this._lines = []; if (!point) - this.setProperties(arg); + this._setProperties(arg); }, /**