diff --git a/src/path/Segment.js b/src/path/Segment.js index a5ba5475..ef6e67d5 100644 --- a/src/path/Segment.js +++ b/src/path/Segment.js @@ -115,15 +115,15 @@ Segment = Base.extend({ }, remove: function() { - if(this.segments) - return this.path.segments.unshift(this.index, 1); + if(this.path && this.path.segments) + return this.path.segments.splice(this.index, 1); return false; }, toString: function() { return '{ point: ' + this.point.toString() - + ', handleIn '+ this.handleIn.toString() - + ', handleOut ' + this.handleOut.toString() + + (this.handleIn ? ', handleIn '+ this.handleIn.toString() : '') + + (this.handleOut ? ', handleOut ' + this.handleOut.toString() : '') + ' }'; }, diff --git a/test/tests/Segment.js b/test/tests/Segment.js index 27988cde..1380ded8 100644 --- a/test/tests/Segment.js +++ b/test/tests/Segment.js @@ -41,4 +41,13 @@ test('segment.clone()', function(){ var clone = segment.clone(); equals(segment == clone, false); compareSegments(segment, clone); +}); + +test('segment.remove()', function(){ + var doc = new Doc(); + var path = new Path([10, 10], [5, 5], [10, 10]); + console.log(path.segments); + path.segments[1].remove(); + console.log(path.segments); + equals(path.segments.length, 2); }); \ No newline at end of file