From 56391060c41f979dbac276037b84fd7ddb06c2b4 Mon Sep 17 00:00:00 2001 From: kerryliu Date: Tue, 15 Jul 2014 13:54:10 -0700 Subject: [PATCH] create ids that start with a letter --- canvas2svg.js | 4 ++-- jasmine-tests/spec/canvas2svgspec.js | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/canvas2svg.js b/canvas2svg.js index a45c68d..898a3f8 100644 --- a/canvas2svg.js +++ b/canvas2svg.js @@ -1,5 +1,5 @@ /*!! - * Canvas 2 Svg v1.0.3 + * Canvas 2 Svg v1.0.4 * A low level canvas to SVG converter. Uses a mock canvas context to build an SVG document. * * Licensed under the MIT license: @@ -31,7 +31,7 @@ if (!holder) { throw new Error("cannot create a random attribute name for an undefined object"); } - chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; + chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; randomstring = ""; do { randomstring = ""; diff --git a/jasmine-tests/spec/canvas2svgspec.js b/jasmine-tests/spec/canvas2svgspec.js index 16d1924..b4b3cdf 100755 --- a/jasmine-tests/spec/canvas2svgspec.js +++ b/jasmine-tests/spec/canvas2svgspec.js @@ -117,11 +117,22 @@ describe("canvas2svg", function() { //passing in true will attempt to find all named entities and encode it as a numeric entity. var string = ctx.getSerializedSvg(true); expect(typeof string).toBe("string"); - expect(string).toEqual(''); + expect(string).toEqual(''); }); }); + describe("it will generate ids", function() { + + it("that start with a letter", function() { + var ctx = new C2S(); + ctx.createRadialGradient(6E1, 6E1, 0.0, 6E1, 6E1, 5E1); + var svg = ctx.getSvg(); + var id = svg.children[0].children[0].id; + var test = /^[A-Za-z]/.test(id); + expect(test).toEqual(true); + }); + }); describe("will split up rgba", function() { //while browsers support rgba values for fill/stroke, this is not accepted in visio/illustrator