From 63628be9234b52d286ab352c5fc0f59f89262b3b Mon Sep 17 00:00:00 2001 From: Jonathan Puckey Date: Mon, 25 Jul 2011 21:41:09 +0200 Subject: [PATCH] Fix bug in CompoundPath#draw(ctx, draw) which was causing an error when a compound path didn't have any children. --- src/path/CompoundPath.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/path/CompoundPath.js b/src/path/CompoundPath.js index 709ff3f4..93fa12f2 100644 --- a/src/path/CompoundPath.js +++ b/src/path/CompoundPath.js @@ -85,10 +85,15 @@ var CompoundPath = this.CompoundPath = PathItem.extend(/** @lends CompoundPath# }, draw: function(ctx, param) { + var l = this._children.length; + // Return early if the compound path doesn't have any children: + if (l == 0) { + return; + } var firstChild = this._children[0]; ctx.beginPath(); param.compound = true; - for (var i = 0, l = this._children.length; i < l; i++) + for (var i = 0; i < l; i++) Item.draw(this._children[i], ctx, param); firstChild._setStyles(ctx); var fillColor = firstChild.getFillColor(),