From 26b7ac05a1d44059d22c19737b676d7b136cc1ca Mon Sep 17 00:00:00 2001 From: Flint O'Brien Date: Sat, 30 Apr 2016 21:11:02 -0400 Subject: [PATCH] Fixed bug with getCurrentLayer when no current layer. --- editor/draw.js | 2 +- test/draw_test.html | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/editor/draw.js b/editor/draw.js index 41483479..79515b9d 100644 --- a/editor/draw.js +++ b/editor/draw.js @@ -414,7 +414,7 @@ svgedit.draw.Drawing.prototype.getLayerName = function (i) { * @returns {SVGGElement} The SVGGElement representing the current layer. */ svgedit.draw.Drawing.prototype.getCurrentLayer = function() { - return this.current_layer.getGroup(); + return this.current_layer ? this.current_layer.getGroup() : null; }; /** diff --git a/test/draw_test.html b/test/draw_test.html index 09cf1792..fc0eca47 100644 --- a/test/draw_test.html +++ b/test/draw_test.html @@ -248,9 +248,10 @@ }); test('Test identifyLayers() with empty document', function() { - expect(10); + expect(11); var drawing = new svgedit.draw.Drawing(svg); + equals(drawing.getCurrentLayer(), null); // By default, an empty document gets an empty group created. drawing.identifyLayers();