mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-19 07:19:41 +02:00
fix: failing unit test
on-behalf-of: @Mermaid-Chart <hello@mermaidchart.com>
This commit is contained in:
@@ -163,25 +163,32 @@ export const replaceEndpoint = (
|
|||||||
value: P | null | undefined,
|
value: P | null | undefined,
|
||||||
tol = 0.1
|
tol = 0.1
|
||||||
) => {
|
) => {
|
||||||
if (!value) {
|
if (!value || points.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const isDup = points.some((p, i) =>
|
|
||||||
which === 'start'
|
if (which === 'start') {
|
||||||
? i > 0 && Math.abs(p.x - value.x) < tol && Math.abs(p.y - value.y) < tol
|
if (
|
||||||
: i < points.length - 1 && Math.abs(p.x - value.x) < tol && Math.abs(p.y - value.y) < tol
|
points.length > 0 &&
|
||||||
);
|
Math.abs(points[0].x - value.x) < tol &&
|
||||||
if (isDup) {
|
Math.abs(points[0].y - value.y) < tol
|
||||||
if (which === 'start') {
|
) {
|
||||||
|
// duplicate start remove it
|
||||||
points.shift();
|
points.shift();
|
||||||
} else {
|
} else {
|
||||||
points.pop();
|
points[0] = value;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (which === 'start') {
|
const last = points.length - 1;
|
||||||
points[0] = value;
|
if (
|
||||||
|
points.length > 0 &&
|
||||||
|
Math.abs(points[last].x - value.x) < tol &&
|
||||||
|
Math.abs(points[last].y - value.y) < tol
|
||||||
|
) {
|
||||||
|
// duplicate end remove it
|
||||||
|
points.pop();
|
||||||
} else {
|
} else {
|
||||||
points[points.length - 1] = value;
|
points[last] = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user