From 8842d47817e209725dc450a976f984bd5486e48a Mon Sep 17 00:00:00 2001 From: Luis Blanco Date: Wed, 26 Jun 2024 11:14:41 +0400 Subject: [PATCH] Prevent webgl.init crash --- js/document.js | 10 ++++++++-- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/js/document.js b/js/document.js index 0f2cebd..28109bc 100644 --- a/js/document.js +++ b/js/document.js @@ -24,8 +24,12 @@ class Document extends Window { super(opts); if (Document.webgl && !Document.isWebglInited) { - if (typeof Document.webgl.init === 'function') { - Document.webgl.init(); + try { + if (typeof Document.webgl.init === 'function') { + Document.webgl.init(); + } + } catch (_e) { + console.warn('WebGL `init()` call failed, but it may still work.'); } Document.isWebglInited = true; } @@ -100,6 +104,8 @@ class Document extends Window { } + getRootNode() { return this; } + getElementById() { return this; } getElementsByTagName() { return [this]; } diff --git a/package-lock.json b/package-lock.json index f234f6b..ca3c37e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "glfw-raub", - "version": "5.5.0", + "version": "5.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "glfw-raub", - "version": "5.5.0", + "version": "5.6.0", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index eb4f17c..3736ee7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Luis Blanco ", "name": "glfw-raub", - "version": "5.5.0", + "version": "5.6.0", "description": "GLFW for Node.js", "license": "MIT", "main": "index.js",