From 2230c2888d2a48dd75de373c7e411749d67c0743 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Fri, 1 Mar 2013 20:19:44 -0800 Subject: [PATCH] Fix issue with Curve#divide() where the wrong curve reference is returned. --- src/path/Curve.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/path/Curve.js b/src/path/Curve.js index bd73c1c9..55935043 100644 --- a/src/path/Curve.js +++ b/src/path/Curve.js @@ -344,12 +344,17 @@ var Curve = this.Curve = Base.extend(/** @lends Curve# */{ if (this._path) { // Insert at the end if this curve is a closing curve of a // closed path, since otherwise it would be inserted at 0. - if (this._segment1._index > 0 && this._segment2._index == 0) { + if (this._segment1._index > 0 && this._segment2._index === 0) { this._path.add(segment); } else { this._path.insert(this._segment2._index, segment); } - res = this.getNext(); + // The way Path#_add handles curves, this curve will always + // become the owner of the newly inserted segment. + // TODO: I expect this.getNext() to produce the correct result, + // but since we're inserting differently in _add (something + // linked with CurveLocation#dividie()), this is not the case... + res = this; } else { // otherwise create it from the result of split var end = this._segment2;