Avoid CompoundPath#reduce() in SVG path import by improving regular expression that identifies the need for CompoundPath.

This commit is contained in:
Jürg Lehni 2014-03-13 01:01:26 +01:00
parent e80991658b
commit 0bca1656ac

View file

@ -130,10 +130,15 @@ new function() {
}
function importPath(node) {
return new CompoundPath({
pathData: node.getAttribute('d'),
insert: false
}).reduce();
// Get the path data, and determine whether it is a compound path or a
// normal path based on the amount of moveTo commands inside it.
var data = node.getAttribute('d'),
param = { pathData: data, insert: false };
// If there are multiple moveTo commands or a closePath command followed
// by other commands, we have a CompoundPath:
return data.match(/m/gi).length > 1 || /z\S+/i.test(data)
? new CompoundPath(param)
: new Path(param);
}
function importGradient(node, type) {