set canvas style to override problem 3rd party css
move typecast for simplicity
This commit is contained in:
+7
-5
@@ -19,12 +19,16 @@ export function createCanvasContext2D(
|
|||||||
opt_canvasPool,
|
opt_canvasPool,
|
||||||
opt_Context2DSettings
|
opt_Context2DSettings
|
||||||
) {
|
) {
|
||||||
const canvas =
|
const canvas = /** @type {HTMLCanvasElement} */ (
|
||||||
opt_canvasPool && opt_canvasPool.length
|
opt_canvasPool && opt_canvasPool.length
|
||||||
? opt_canvasPool.shift()
|
? opt_canvasPool.shift()
|
||||||
: WORKER_OFFSCREEN_CANVAS
|
: WORKER_OFFSCREEN_CANVAS
|
||||||
? new OffscreenCanvas(opt_width || 300, opt_height || 300)
|
? new OffscreenCanvas(opt_width || 300, opt_height || 300)
|
||||||
: document.createElement('canvas');
|
: document.createElement('canvas')
|
||||||
|
);
|
||||||
|
if (canvas.style) {
|
||||||
|
canvas.style.all = 'initial';
|
||||||
|
}
|
||||||
if (opt_width) {
|
if (opt_width) {
|
||||||
canvas.width = opt_width;
|
canvas.width = opt_width;
|
||||||
}
|
}
|
||||||
@@ -32,9 +36,7 @@ export function createCanvasContext2D(
|
|||||||
canvas.height = opt_height;
|
canvas.height = opt_height;
|
||||||
}
|
}
|
||||||
//FIXME Allow OffscreenCanvasRenderingContext2D as return type
|
//FIXME Allow OffscreenCanvasRenderingContext2D as return type
|
||||||
return /** @type {CanvasRenderingContext2D} */ (
|
return canvas.getContext('2d', opt_Context2DSettings);
|
||||||
canvas.getContext('2d', opt_Context2DSettings)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user