fix: Validate if WebGLRenderingContext exists before capturing it (#1777)

* Update webgl.ts

---------

Co-authored-by: Paul D'Ambra <paul.dambra@gmail.com>
Co-authored-by: Justin Halsall <Juice10@users.noreply.github.com>
This commit is contained in:
Christopher Arredondo
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 42c203d24f
commit 8df3133af5
2 changed files with 17 additions and 10 deletions

View File

@@ -95,16 +95,18 @@ export default function initCanvasWebGLMutationObserver(
): listenerHandler {
const handlers: listenerHandler[] = [];
handlers.push(
...patchGLPrototype(
win.WebGLRenderingContext.prototype,
CanvasContext.WebGL,
cb,
blockClass,
blockSelector,
win,
),
);
if (typeof win.WebGLRenderingContext !== 'undefined') {
handlers.push(
...patchGLPrototype(
win.WebGLRenderingContext.prototype,
CanvasContext.WebGL,
cb,
blockClass,
blockSelector,
win,
),
);
}
if (typeof win.WebGL2RenderingContext !== 'undefined') {
handlers.push(