mirror of
https://github.com/konvajs/konva.git
synced 2025-11-24 16:53:06 +08:00
better path2 polifill for node envs
This commit is contained in:
@@ -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']) {
|
||||
|
||||
@@ -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`;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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`;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user