diff --git a/src/svg/SvgExport.js b/src/svg/SvgExport.js index ecf19f23..394f194f 100644 --- a/src/svg/SvgExport.js +++ b/src/svg/SvgExport.js @@ -326,8 +326,8 @@ new function() { definitions = { ids: {}, svgs: {} }; // Use #__id for items that don't have internal #_id properties (Color), // and give them ids from their own private id pool named 'svg'. - var id = item._id || item.__id || (item.__id = UID.get('svg')); - return item && definitions.svgs[type + '-' + id]; + return item && definitions.svgs[type + '-' + + (item._id || item.__id || (item.__id = UID.get('svg')))]; } function setDefinition(item, node, type) { diff --git a/test/helpers.js b/test/helpers.js index e6473a4a..492ef934 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -217,11 +217,9 @@ var comparePixels = function(actual, expected, message, options) { var tolerance = (options.tolerance || 1e-4) * 100, fixed = tolerance < 1 ? ((1 / tolerance) + '').length - 1 : 0, identical = result ? 100 - result.misMatchPercentage : 0, - reached = identical.toFixed(fixed), - hundred = (100).toFixed(fixed), - ok = reached == hundred, - text = reached + '% identical'; - QUnit.push(ok, text, hundred + '% identical', message); + ok = Math.abs(100 - identical) <= tolerance, + text = identical.toFixed(fixed) + '% identical'; + QUnit.push(ok, text, (100).toFixed(fixed) + '% identical', message); if (!ok && result && !isNode) { // Get the right entry for this unit test and assertion, and // replace the results with images diff --git a/test/tests/SvgExport.js b/test/tests/SvgExport.js index 6e4b803a..a68f6cd3 100644 --- a/test/tests/SvgExport.js +++ b/test/tests/SvgExport.js @@ -191,4 +191,25 @@ if (!isNode) { tolerance: 1e-2 }); }); + + test('Export SVG with clipping defs', function(assert) { + var group = new Group({ + children: [ + new Path.Circle({ + center: [150, 150], + radius: 50 + }), + new Path.Rectangle({ + point: [100, 100], + size: [100, 100], + fillColor: 'green' + }) + ], + clipped: true + }); + var svg = project.exportSVG({ bounds: 'content', asString: true }); + compareSVG(assert.async(), svg, project.activeLayer, null, { + tolerance: 1e-2 + }); + }); }