From 905d1106d4a783e3c62f48d9753075ddfeda4fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Fri, 2 Nov 2012 19:10:58 -0700 Subject: [PATCH] Fix SVGImporter tests for all polygon related code. #length was used instead of #numberOfItems. --- src/svg/SvgImporter.js | 2 +- test/tests/SvgImporter.js | 40 ++++++++++++--------------------------- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/src/svg/SvgImporter.js b/src/svg/SvgImporter.js index 66b47697..872c2407 100644 --- a/src/svg/SvgImporter.js +++ b/src/svg/SvgImporter.js @@ -46,7 +46,7 @@ var SvgImporter = this.SvgImporter = new function() { points = svg.points, start = points.getItem(0); poly.moveTo(start); - for (var i = 1; i < points.length; i++) + for (var i = 1, l = points.numberOfItems; i < l; i++) poly.lineTo(points.getItem(i)); if (svg.nodeName.toLowerCase() == 'polygon') poly.closePath(); diff --git a/test/tests/SvgImporter.js b/test/tests/SvgImporter.js index 36095911..66489e20 100644 --- a/test/tests/SvgImporter.js +++ b/test/tests/SvgImporter.js @@ -331,13 +331,9 @@ test('compare polygon values', function() { var poly = new Path(); var points = shape.points; - var start = points.getItem(0); - var point; - poly.moveTo([start.x, start.y]); - - for (var i = 1; i < points.length; i++) { - point = points.getItem(i); - poly.lineTo([point.x, point.y]); + poly.moveTo(points.getItem(0)); + for (var i = 1; i < points.numberOfItems; i++) { + poly.lineTo(points.getItem(i)); } if (shape.nodeName.toLowerCase() == 'polygon') { poly.closePath(); @@ -356,13 +352,9 @@ test('compare negative polygon values', function() { var poly = new Path(); var points = shape.points; - var start = points.getItem(0); - var point; - poly.moveTo([start.x, start.y]); - - for (var i = 1; i < points.length; i++) { - point = points.getItem(i); - poly.lineTo([point.x, point.y]); + poly.moveTo(points.getItem(0)); + for (var i = 1; i < points.numberOfItems; i++) { + poly.lineTo(points.getItem(i)); } if (shape.nodeName.toLowerCase() == 'polygon') { poly.closePath(); @@ -381,13 +373,9 @@ test('compare polyline values', function() { var poly = new Path(); var points = shape.points; - var start = points.getItem(0); - var point; - poly.moveTo([start.x, start.y]); - - for (var i = 1; i < points.length; i++) { - point = points.getItem(i); - poly.lineTo([point.x, point.y]); + poly.moveTo(points.getItem(0)); + for (var i = 1; i < points.numberOfItems; i++) { + poly.lineTo(points.getItem(i)); } if (shape.nodeName.toLowerCase() == 'polygon') { poly.closePath(); @@ -406,13 +394,9 @@ test('compare negative polyline values', function() { var poly = new Path(); var points = shape.points; - var start = points.getItem(0); - var point; - poly.moveTo([start.x, start.y]); - - for (var i = 1; i < points.length; i++) { - point = points.getItem(i); - poly.lineTo([point.x, point.y]); + poly.moveTo(points.getItem(0)); + for (var i = 1; i < points.numberOfItems; i++) { + poly.lineTo(points.getItem(i)); } if (shape.nodeName.toLowerCase() == 'polygon') { poly.closePath();