Skip to content

Commit

Permalink
Prevent webgl.init crash
Browse files Browse the repository at this point in the history
  • Loading branch information
raub committed Jun 26, 2024
1 parent b353dc1 commit 8842d47
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
10 changes: 8 additions & 2 deletions js/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -100,6 +104,8 @@ class Document extends Window {
}


getRootNode() { return this; }

getElementById() { return this; }

getElementsByTagName() { return [this]; }
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"author": "Luis Blanco <luisblanco1337@gmail.com>",
"name": "glfw-raub",
"version": "5.5.0",
"version": "5.6.0",
"description": "GLFW for Node.js",
"license": "MIT",
"main": "index.js",
Expand Down

0 comments on commit 8842d47

Please sign in to comment.