better path2 polifill for node envs

This commit is contained in:
Anton Lavrevov
2025-08-23 05:16:02 -05:00
parent 472219adb4
commit e2c0a719b9
3 changed files with 10 additions and 20 deletions

View File

@@ -7,6 +7,16 @@ const canvas = Canvas['default'] || Canvas;
// @ts-ignore
global.DOMMatrix = canvas.DOMMatrix;
(global as any).Path2D ??= class Path2D {
constructor(path: any) {
(this as any).path = path;
}
get [Symbol.toStringTag]() {
return `Path2D`;
}
};
Konva.Util['createCanvasElement'] = () => {
const node = canvas.createCanvas(300, 300) as any;
if (!node['style']) {

View File

@@ -1,13 +1,3 @@
export async function mochaGlobalSetup() {
await import('../src/canvas-backend.ts');
globalThis.Path2D ??= class Path2D {
constructor(path) {
this.path = path;
}
get [Symbol.toStringTag]() {
return `Path2D`;
}
};
}

View File

@@ -1,13 +1,3 @@
export async function mochaGlobalSetup() {
await import('../src/skia-backend.ts');
globalThis.Path2D ??= class Path2D {
constructor(path) {
this.path = path;
}
get [Symbol.toStringTag]() {
return `Path2D`;
}
};
}