Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jussiKC committed May 15, 2023
1 parent 866352a commit afc7e45
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions plugins/mergePaths.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ exports.fn = (root, params) => {
let prevChild = null;
let prevPathJS = null;

const saveCurrent = () =>
{
const saveCurrent = () => {
js2path(prevChild, prevPathJS, {
floatPrecision,
noSpaceAfterFlags,
});
prevPathJS = null;
}
};
for (const child of node.children) {
// skip if previous element is not path or contains animation elements
if (
Expand All @@ -44,7 +43,7 @@ exports.fn = (root, params) => {
prevChild.children.length !== 0 ||
prevChild.attributes.d == null
) {
if(prevPathJS) {
if (prevPathJS) {
saveCurrent();
}
prevChild = child;
Expand All @@ -58,7 +57,7 @@ exports.fn = (root, params) => {
child.children.length !== 0 ||
child.attributes.d == null
) {
if(prevPathJS) {
if (prevPathJS) {
saveCurrent();
}
prevChild = child;
Expand All @@ -72,7 +71,7 @@ exports.fn = (root, params) => {
computedStyle['marker-mid'] ||
computedStyle['marker-end']
) {
if(prevPathJS) {
if (prevPathJS) {
saveCurrent();
}
prevChild = child;
Expand All @@ -92,7 +91,7 @@ exports.fn = (root, params) => {
}
}
const hasPrevPath = !!prevPathJS;
if(!hasPrevPath) prevPathJS = path2js(prevChild);
if (!hasPrevPath) prevPathJS = path2js(prevChild);
const curPathJS = path2js(child);

if (
Expand All @@ -105,16 +104,18 @@ exports.fn = (root, params) => {
continue;
}

if(hasPrevPath) {
if (hasPrevPath) {
saveCurrent();
}
prevPathJS = null;
prevChild = child;
}
if(prevPathJS) {
if (prevPathJS) {
saveCurrent();
}
node.children = node.children.filter(child => !child._deleteAfterwards);
node.children = node.children.filter(
(child) => !child._deleteAfterwards
);
},
},
};
Expand Down

0 comments on commit afc7e45

Please sign in to comment.