flatten-svg
Advanced tools
Comparing version 0.1.4 to 0.2.0
@@ -54,2 +54,3 @@ "use strict"; | ||
case 'g': | ||
case 'a': | ||
for (const child of svgEl.children) { | ||
@@ -77,3 +78,3 @@ yield* walkSvgShapes(child); | ||
} | ||
else if (shape.parentNode) { | ||
if (shape.parentNode) { | ||
return getStroke(shape.parentNode); | ||
@@ -83,2 +84,13 @@ } | ||
} | ||
function getGroupId(shape) { | ||
if (!shape) | ||
return null; | ||
if (shape.id && shape.nodeName.toLowerCase() === 'g') { | ||
return shape.id; | ||
} | ||
if (shape.parentNode) { | ||
return getGroupId(shape.parentNode); | ||
} | ||
return null; | ||
} | ||
function flattenSVG(svg, options = {}) { | ||
@@ -108,2 +120,3 @@ const { maxError = 0.1 } = options; | ||
stroke: getStroke(shape), | ||
groupId: getGroupId(shape) | ||
}); | ||
@@ -110,0 +123,0 @@ } |
{ | ||
"name": "flatten-svg", | ||
"version": "0.1.4", | ||
"version": "0.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
87877
1074