set canvas style to override problem 3rd party css

move typecast for simplicity
This commit is contained in:
mike-000
2021-08-15 22:09:33 +01:00
parent 44ec78749f
commit 78c105e838
+7 -5
View File
@@ -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)
);
} }
/** /**