mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2024-12-29 09:22:22 -05:00
Merge pull request #28 from adroitwhiz/dont-export-undef-llk
Don't apply undefined styles in exportSVG + handle invalid fill-rule in importer
This commit is contained in:
commit
112047f5ad
2 changed files with 14 additions and 1 deletions
|
@ -304,6 +304,12 @@ new function() {
|
||||||
var get = entry.get,
|
var get = entry.get,
|
||||||
type = entry.type,
|
type = entry.type,
|
||||||
value = item[get]();
|
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
|
if (entry.exportFilter
|
||||||
? entry.exportFilter(item, value)
|
? entry.exportFilter(item, value)
|
||||||
: !parent || !Base.equals(parent[get](), value) ||
|
: !parent || !Base.equals(parent[get](), value) ||
|
||||||
|
|
|
@ -531,7 +531,14 @@ new function() {
|
||||||
if (matrix)
|
if (matrix)
|
||||||
group.transform(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;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function getAttribute(node, name, styles) {
|
function getAttribute(node, name, styles) {
|
||||||
|
|
Loading…
Reference in a new issue