From f1a6357a05d1e221a41063353d9c9f442575c7d1 Mon Sep 17 00:00:00 2001 From: Alex Buchanan Date: Sat, 18 Feb 2012 15:13:23 -0800 Subject: [PATCH] Path.reverse() should adjust segment indices --- src/path/Path.js | 2 ++ test/tests/Path.js | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/path/Path.js b/src/path/Path.js index 64e347cb..53c785ab 100644 --- a/src/path/Path.js +++ b/src/path/Path.js @@ -828,6 +828,8 @@ var Path = this.Path = PathItem.extend(/** @lends Path# */{ var handleIn = segment._handleIn; segment._handleIn = segment._handleOut; segment._handleOut = handleIn; + // Adjust index + segment._index = i; } // Flip clockwise state if it's defined if (this._clockwise !== undefined) diff --git a/test/tests/Path.js b/test/tests/Path.js index a0bfe742..d445c7ba 100644 --- a/test/tests/Path.js +++ b/test/tests/Path.js @@ -265,6 +265,14 @@ test('Path#reverse', function() { equals(path.segments.toString(), '{ point: { x: 100, y: 130 }, handleIn: { x: -16.56854, y: 0 }, handleOut: { x: 16.56854, y: 0 } },{ point: { x: 130, y: 100 }, handleIn: { x: 0, y: 16.56854 }, handleOut: { x: 0, y: -16.56854 } },{ point: { x: 100, y: 70 }, handleIn: { x: 16.56854, y: 0 }, handleOut: { x: -16.56854, y: 0 } },{ point: { x: 70, y: 100 }, handleIn: { x: 0, y: -16.56854 }, handleOut: { x: 0, y: 16.56854 } }'); }); +test('#reverse should adjust segment indices', function() { + var path = new Path([[0, 0], [10, 10], [20, 20]]); + path.reverse(); + equals(path.segments[0]._index, 0); + equals(path.segments[1]._index, 1); + equals(path.segments[2]._index, 2); +}); + test('Path#fullySelected', function() { var path = new Path.Circle([100, 100], 10); path.fullySelected = true; @@ -272,4 +280,4 @@ test('Path#fullySelected', function() { equals(function() { return path.fullySelected; }, false); -}); \ No newline at end of file +});