diff --git a/src/core/Base.js b/src/core/Base.js index be36b0c7..3c384085 100644 --- a/src/core/Base.js +++ b/src/core/Base.js @@ -70,7 +70,7 @@ this.Base = Base.inject(/** @lends Base# */{ * @return {Boolean} {@true if the object is a plain object} */ _set: function(props) { - if (Base.isPlainObject(props)) { + if (props && Base.isPlainObject(props)) { for (var key in props) if (props.hasOwnProperty(key) && key in this) this[key] = props[key]; diff --git a/src/item/Group.js b/src/item/Group.js index 629cfe16..98c91c00 100644 --- a/src/item/Group.js +++ b/src/item/Group.js @@ -93,7 +93,7 @@ var Group = this.Group = Item.extend(/** @lends Group# */{ // Allow Group to have children and named children this._children = []; this._namedChildren = {}; - if (!this._set(arg)) + if (arg && !this._set(arg)) this.addChildren(Array.isArray(arg) ? arg : arguments); }, diff --git a/src/item/Item.js b/src/item/Item.js index 9485f051..fe24a9d0 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -235,7 +235,8 @@ var Item = this.Item = Base.extend(Callback, { * }); */ set: function(props) { - this._set(props); + if (props) + this._set(props); return this; }, diff --git a/src/item/PlacedSymbol.js b/src/item/PlacedSymbol.js index c16f94a3..2fdf2e60 100644 --- a/src/item/PlacedSymbol.js +++ b/src/item/PlacedSymbol.js @@ -72,7 +72,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._set(arg0)) + if (arg0 && !this._set(arg0)) this.setSymbol(arg0 instanceof Symbol ? arg0 : new Symbol(arg0)); }, diff --git a/src/path/CompoundPath.js b/src/path/CompoundPath.js index 8f93d154..755c0284 100644 --- a/src/path/CompoundPath.js +++ b/src/path/CompoundPath.js @@ -54,7 +54,7 @@ var CompoundPath = this.CompoundPath = PathItem.extend(/** @lends CompoundPath# // CompoundPath has children and supports named children. this._children = []; this._namedChildren = {}; - if (!this._set(arg)) + if (arg && !this._set(arg)) this.addChildren(Array.isArray(arg) ? arg : arguments); }, diff --git a/src/path/Path.Constructors.js b/src/path/Path.Constructors.js index 044e1517..90d63538 100644 --- a/src/path/Path.Constructors.js +++ b/src/path/Path.Constructors.js @@ -13,7 +13,11 @@ Path.inject({ statics: new function() { function createPath(args) { - return new Path().set(Base.getNamed(args)); + var path = new Path(), + named = Base.getNamed(args); + if (named) + path._set(named); + return path; } function createRectangle(/* rect */) { diff --git a/src/path/Path.js b/src/path/Path.js index 04e86cf6..d8ff945e 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -86,7 +86,7 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{ ? arguments : null; this.setSegments(segments || []); - if (!segments) + if (arg && !segments) this._set(arg); }, diff --git a/src/text/TextItem.js b/src/text/TextItem.js index 44cc25b6..fe756541 100644 --- a/src/text/TextItem.js +++ b/src/text/TextItem.js @@ -41,7 +41,7 @@ var TextItem = this.TextItem = Item.extend(/** @lends TextItem# */{ this._paragraphStyle = ParagraphStyle.create(this); // See if a point is passed, and if so, pass it on to base(). If not, it // might be a properties object literal for #setPropeties() at the end. - var hasProperties = Base.isPlainObject(arg) + var hasProperties = arg && Base.isPlainObject(arg) && arg.x === undefined && arg.y === undefined; this.base(hasProperties ? null : Point.read(arguments)); // No need to call setStyle(), since base() handles this already. @@ -49,9 +49,8 @@ var TextItem = this.TextItem = Item.extend(/** @lends TextItem# */{ this.setParagraphStyle(); this._content = ''; this._lines = []; - if (hasProperties) { + if (hasProperties) this._set(arg); - } }, /**