From d4eb298c44cf847b2da1f78a5191a66849488b61 Mon Sep 17 00:00:00 2001 From: Jeff Schiller Date: Tue, 29 Sep 2009 13:50:47 +0000 Subject: [PATCH] Fix Issue 245: Webkit normalizes points attribute, dropping commas. Merge Peter's patch in git-svn-id: http://svg-edit.googlecode.com/svn/trunk@728 eee81c28-f429-11dd-99c0-75d572ba1ddd --- editor/svgcanvas.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/editor/svgcanvas.js b/editor/svgcanvas.js index 32bff206..1a97f7df 100644 --- a/editor/svgcanvas.js +++ b/editor/svgcanvas.js @@ -2354,8 +2354,17 @@ function BatchCommand(text) { }); return; case "path": - var coordnum = element.getAttribute('points').split(',').length - 1; - keep = coordnum > 1; + // Check that the path contains at least 2 points; a degenerate one-point path + // causes problems. + // Webkit ignores how we set the points attribute with commas and uses space + // to separate all coordinates, see https://bugs.webkit.org/show_bug.cgi?id=29870 + var coords = element.getAttribute('points'); + var commaIndex = coords.indexOf(','); + if (commaIndex >= 0) { + keep = coords.indexOf(',', commaIndex+1) >= 0; + } else { + keep = coords.indexOf(' ', coords.indexOf(' ')+1) >= 0; + } break; case "line": keep = (element.getAttribute('x1') != element.getAttribute('x2') ||