set initial style after document.createElement
This commit is contained in:
+11
-9
@@ -19,14 +19,14 @@ export function createCanvasContext2D(
|
|||||||
opt_canvasPool,
|
opt_canvasPool,
|
||||||
opt_Context2DSettings
|
opt_Context2DSettings
|
||||||
) {
|
) {
|
||||||
const canvas = /** @type {HTMLCanvasElement} */ (
|
/** @type {HTMLCanvasElement|OffscreenCanvas} */
|
||||||
opt_canvasPool && opt_canvasPool.length
|
let canvas;
|
||||||
? opt_canvasPool.shift()
|
if (opt_canvasPool && opt_canvasPool.length) {
|
||||||
: WORKER_OFFSCREEN_CANVAS
|
canvas = opt_canvasPool.shift();
|
||||||
? new OffscreenCanvas(opt_width || 300, opt_height || 300)
|
} else if (WORKER_OFFSCREEN_CANVAS) {
|
||||||
: document.createElement('canvas')
|
canvas = new OffscreenCanvas(opt_width || 300, opt_height || 300);
|
||||||
);
|
} else {
|
||||||
if (canvas.style) {
|
canvas = document.createElement('canvas');
|
||||||
canvas.style.all = 'initial';
|
canvas.style.all = 'initial';
|
||||||
}
|
}
|
||||||
if (opt_width) {
|
if (opt_width) {
|
||||||
@@ -36,7 +36,9 @@ export function createCanvasContext2D(
|
|||||||
canvas.height = opt_height;
|
canvas.height = opt_height;
|
||||||
}
|
}
|
||||||
//FIXME Allow OffscreenCanvasRenderingContext2D as return type
|
//FIXME Allow OffscreenCanvasRenderingContext2D as return type
|
||||||
return canvas.getContext('2d', opt_Context2DSettings);
|
return /** @type {CanvasRenderingContext2D} */ (
|
||||||
|
canvas.getContext('2d', opt_Context2DSettings)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user