Don't apply undefined styles in exportSVG

This commit is contained in:
adroitwhiz 2019-11-08 20:51:15 -05:00
parent bd2252651b
commit e0009020ed
2 changed files with 14 additions and 1 deletions

View file

@ -304,6 +304,12 @@ new function() {
var get = entry.get,
type = entry.type,
value = item[get]();
// In some cases, the style's value is undefined. Trying to save it
// will result in erroneous behavior; for instance, properties like
// "fill-rule" will have the invalid value of "none" if undefined.
if (value === undefined) return;
if (entry.exportFilter
? entry.exportFilter(item, value)
: !parent || !Base.equals(parent[get](), value) ||

View file

@ -531,6 +531,13 @@ new function() {
if (matrix)
group.transform(matrix);
}
},
'fill-rule': function(item, value) {
// Sometimes, the fill-rule attribute will be set to "none" due to a paper.js bug.
// This is coerced into a `null`. A null `fillRule` will cause certain operaions to error out.
// So, only set the fill rule if it's one of the two valid options: "evenodd" and "nonzero".
if (value === 'evenodd' || value === 'nonzero') item.fillRule = value;
}
});