From 41feaebb4e80567838a4ce57a911b381f27688b6 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Tue, 14 Jun 2011 12:15:46 +0200 Subject: [PATCH 1/2] Fix Group clipping and ignore Item#clipMask in the documentation for now. --- src/item/Group.js | 5 ++--- src/item/Item.js | 4 ++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/item/Group.js b/src/item/Group.js index eb16ba08..03be8f00 100644 --- a/src/item/Group.js +++ b/src/item/Group.js @@ -103,10 +103,9 @@ var Group = this.Group = Item.extend({ draw: function(ctx, param) { for (var i = 0, l = this._children.length; i < l; i++) { + // the group is clipped on its first child + param.clip = this._clipped && i == 0; Item.draw(this._children[i], ctx, param); - // TODO: Shouldn't clipping paths not be filled / stroked? - if (this._clipped && i == 0) - ctx.clip(); } } }); diff --git a/src/item/Item.js b/src/item/Item.js index c1f88ec8..4ed5a990 100644 --- a/src/item/Item.js +++ b/src/item/Item.js @@ -273,6 +273,9 @@ var Item = this.Item = Base.extend({ */ visible: true, + // TODO Item#clipMask is currently not used for clipping - consider + // taking it out, as we could also simply always use the first child as the + // clipping mask. /** * Specifies whether the item defines a clip mask. This can only be set on * paths, compound paths, and text frame objects, and only if the item is @@ -281,6 +284,7 @@ var Item = this.Item = Base.extend({ * @type Boolean * @default false * @bean + * @ignore // ignoring this until we actually make use of it for drawing */ isClipMask: function() { return this._clipMask; From e69395ced045291cdc74097d53548665d11672e6 Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Tue, 14 Jun 2011 12:19:54 +0200 Subject: [PATCH 2/2] Add failing test. --- test/tests/Path.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/tests/Path.js b/test/tests/Path.js index 9e6af806..91cd636b 100644 --- a/test/tests/Path.js +++ b/test/tests/Path.js @@ -114,6 +114,21 @@ test('Is the path deselected after setting a new list of segments?', function() }, 0); }); +test('After setting Path#selected=true on an empty path, subsequent segments should be selected', function() { + var path = new Path(); + path.selected = true; + equals(function() { + return path.selected; + }, true); + path.add([10, 10]); + equals(function() { + return path.selected; + }, true); + equals(function() { + return path.firstSegment.selected; + }, true); +}); + test('Path#reverse', function() { var path = new Path.Circle([100, 100], 30); path.reverse();