Skip to content

Commit

Permalink
semantics
Browse files Browse the repository at this point in the history
  • Loading branch information
KTibow committed Mar 2, 2024
1 parent db5004e commit 01f2a58
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions lib/svgo/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,12 @@ export const includesUrlReference = (body) => {
};

/**
* Checks if changing the path would cause the element to look different.
* Checks if changing the position or size of an element would
* cause the element to look different.
* @param {import('../types.js').ComputedStyles} computedStyle
* @returns {boolean} If it's safe to change the path.
* @returns {boolean} If it's safe to change the position.
*/
export const canChangePath = (computedStyle) => {
export const canChangePosition = (computedStyle) => {
if (computedStyle['marker-start']) return false;
if (computedStyle['marker-mid']) return false;
if (computedStyle['marker-end']) return false;
Expand Down
2 changes: 1 addition & 1 deletion plugins/applyTransformsShapes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { collectStylesheet, computeStyle } from '../lib/style.js';
import {
toFixed,
removeLeadingZero,
canChangePath,
canChangePosition,
} from '../lib/svgo/tools.js';
import { attrsGroupsDefaults } from './_collections.js';
import { transform2js, transformsMultiply } from './_transforms.js';
Expand Down
4 changes: 2 additions & 2 deletions plugins/mergePaths.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import { collectStylesheet, computeStyle } from '../lib/style.js';
import { path2js, js2path, intersects } from './_path.js';
import { canChangePath } from '../lib/svgo/tools.js';
import { canChangePosition } from '../lib/svgo/tools.js';

export const name = 'mergePaths';
export const description = 'merges multiple paths in one if possible';
Expand Down Expand Up @@ -83,7 +83,7 @@ export const fn = (root, params) => {
}

const computedStyle = computeStyle(stylesheet, child);
if (!canChangePath(computedStyle)) {
if (!canChangePosition(computedStyle)) {
if (prevPathData) {
updatePreviousPath(prevChild, prevPathData);
}
Expand Down

0 comments on commit 01f2a58

Please sign in to comment.