Fix SVGImporter tests for all polygon related code.

#length was used instead of #numberOfItems.
This commit is contained in:
Jürg Lehni 2012-11-02 19:10:58 -07:00
parent 6937d4c3be
commit 905d1106d4
2 changed files with 13 additions and 29 deletions

View file

@ -46,7 +46,7 @@ var SvgImporter = this.SvgImporter = new function() {
points = svg.points, points = svg.points,
start = points.getItem(0); start = points.getItem(0);
poly.moveTo(start); 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)); poly.lineTo(points.getItem(i));
if (svg.nodeName.toLowerCase() == 'polygon') if (svg.nodeName.toLowerCase() == 'polygon')
poly.closePath(); poly.closePath();

View file

@ -331,13 +331,9 @@ test('compare polygon values', function() {
var poly = new Path(); var poly = new Path();
var points = shape.points; var points = shape.points;
var start = points.getItem(0); poly.moveTo(points.getItem(0));
var point; for (var i = 1; i < points.numberOfItems; i++) {
poly.moveTo([start.x, start.y]); poly.lineTo(points.getItem(i));
for (var i = 1; i < points.length; i++) {
point = points.getItem(i);
poly.lineTo([point.x, point.y]);
} }
if (shape.nodeName.toLowerCase() == 'polygon') { if (shape.nodeName.toLowerCase() == 'polygon') {
poly.closePath(); poly.closePath();
@ -356,13 +352,9 @@ test('compare negative polygon values', function() {
var poly = new Path(); var poly = new Path();
var points = shape.points; var points = shape.points;
var start = points.getItem(0); poly.moveTo(points.getItem(0));
var point; for (var i = 1; i < points.numberOfItems; i++) {
poly.moveTo([start.x, start.y]); poly.lineTo(points.getItem(i));
for (var i = 1; i < points.length; i++) {
point = points.getItem(i);
poly.lineTo([point.x, point.y]);
} }
if (shape.nodeName.toLowerCase() == 'polygon') { if (shape.nodeName.toLowerCase() == 'polygon') {
poly.closePath(); poly.closePath();
@ -381,13 +373,9 @@ test('compare polyline values', function() {
var poly = new Path(); var poly = new Path();
var points = shape.points; var points = shape.points;
var start = points.getItem(0); poly.moveTo(points.getItem(0));
var point; for (var i = 1; i < points.numberOfItems; i++) {
poly.moveTo([start.x, start.y]); poly.lineTo(points.getItem(i));
for (var i = 1; i < points.length; i++) {
point = points.getItem(i);
poly.lineTo([point.x, point.y]);
} }
if (shape.nodeName.toLowerCase() == 'polygon') { if (shape.nodeName.toLowerCase() == 'polygon') {
poly.closePath(); poly.closePath();
@ -406,13 +394,9 @@ test('compare negative polyline values', function() {
var poly = new Path(); var poly = new Path();
var points = shape.points; var points = shape.points;
var start = points.getItem(0); poly.moveTo(points.getItem(0));
var point; for (var i = 1; i < points.numberOfItems; i++) {
poly.moveTo([start.x, start.y]); poly.lineTo(points.getItem(i));
for (var i = 1; i < points.length; i++) {
point = points.getItem(i);
poly.lineTo([point.x, point.y]);
} }
if (shape.nodeName.toLowerCase() == 'polygon') { if (shape.nodeName.toLowerCase() == 'polygon') {
poly.closePath(); poly.closePath();