diff --git a/src/index.ts b/src/index.ts index fd00fac..9c12dcc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -33,6 +33,9 @@ dom.window.HTMLCanvasElement.prototype.getContext = function () { if (arguments[0] === 'webgl') { // create headless-gl GL context const ctx: ReturnType & Partial = createContext(1, 1, arguments[1]) + if (!ctx) { + return ctx + } // insert the resize method to the context so that lcjs package can use it ctx.resize = ctx.getExtension('STACKGL_resize_drawingbuffer').resize return ctx