diff --git a/src/item/Item.js b/src/item/Item.js index 42961f58..644d3672 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -36,9 +36,8 @@ var Item = this.Item = Base.extend({ }, _clone: function(copy) { - // If this item has a pathStyle, copy it: - if (this._style) - copy.setStyle(this._style); + // Copy over style + copy.setStyle(this._style); // If this item has children, clone and append each of them: if (this._children) { for (var i = 0, l = this._children.length; i < l; i++) diff --git a/src/item/PathStyle.js b/src/item/PathStyle.js index 4677a02e..3ec98044 100644 --- a/src/item/PathStyle.js +++ b/src/item/PathStyle.js @@ -63,7 +63,7 @@ var PathStyle = this.PathStyle = Base.extend(new function() { } else { var old = this['_' + key]; if (old != value && !(old && old.equals && old.equals(value))) { - this['_' + key] = value; + this['_' + key] = value && value.clone ? value.clone() : value; if (this._item) { this._item._changed(ChangeFlags.STYLE | (strokeFlags[key] ? ChangeFlags.STROKE : 0)); @@ -83,7 +83,8 @@ var PathStyle = this.PathStyle = Base.extend(new function() { var childStyle = children[i]._style[get](); if (!style) { style = childStyle; - } else if (style != childStyle) { + } else if (style != childStyle && !(style && style.equals + && style.equals(childStyle))) { // If there is another item with a different style, // the style is not defined: // PORT: Change this in Sg (currently returns null) @@ -96,6 +97,7 @@ var PathStyle = this.PathStyle = Base.extend(new function() { } }; + // Style-getters and setters for Item: // 'this' = the Base.each() side-car = the object that is returned from // Base.each and injected into Item above: this[set] = function(value) { diff --git a/src/path/SegmentPoint.js b/src/path/SegmentPoint.js index 3f655fc0..c53bfc58 100644 --- a/src/path/SegmentPoint.js +++ b/src/path/SegmentPoint.js @@ -55,17 +55,20 @@ var SegmentPoint = Point.extend({ }, statics: { - create: function(segment, x, y) { + create: function(segment, x, y, selected) { if (y === undefined) { // Use the normal point constructor to read in point values - var tmp = new Point(x); - x = tmp.x; - y = tmp.y; + var pt = x instanceof Point ? x : new Point(x); + x = pt.x; + y = pt.y; + selected = pt.selected; } var point = new SegmentPoint(SegmentPoint.dont); point._x = x; point._y = y; point._owner = segment; + if (selected) + point.setSelected(true); return point; } } diff --git a/test/tests/Item_Cloning.js b/test/tests/Item_Cloning.js index 2a8c375c..31a23e4e 100644 --- a/test/tests/Item_Cloning.js +++ b/test/tests/Item_Cloning.js @@ -17,7 +17,7 @@ test('Path#clone()', function() { path.locked = true; path.visible = false; path.blendMode = 'blend'; - path._clipMask = true; + path.clipMask = true; path.selected = true; cloneAndCompare(path); }); diff --git a/test/tests/Layer.js b/test/tests/Layer.js index 0e6e0878..28533867 100644 --- a/test/tests/Layer.js +++ b/test/tests/Layer.js @@ -95,7 +95,7 @@ test('appendTop / appendBottom / nesting', function() { return project.layers.length; }, 2); equals(function() { - return project.layers[0] == firstLayer - && project.layers[1] == secondLayer; + return project.layers[0] == secondLayer + && project.layers[1] == firstLayer; }, true); }); \ No newline at end of file