Skip to content

Commit

Permalink
Fix WebMidi.supported not necessarily returning boolean (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Philippe Côté committed Apr 21, 2024
1 parent 878ca1a commit 8d42de2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/WebMidi.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ import {Enumerations} from "./Enumerations.js";

// This code will only be included in the CJS version (CommonJS).

/*
coud we use this instead of eval():
let jzz = await Object.getPrototypeOf(async function() {}).constructor(`
let jzz = await import("jzz");
return jzz.default;
`)();
*/

// If this code is executed by Node.js then we must import the `jzz` module. I import it in this
// convoluted way to prevent Webpack from automatically bundling it in browser bundles where it
// isn't needed.
Expand Down Expand Up @@ -1037,7 +1048,7 @@ class WebMidi extends EventEmitter {
* @type {boolean}
*/
get supported() {
return (typeof navigator !== "undefined" && navigator.requestMIDIAccess);
return (typeof navigator !== "undefined" && !!navigator.requestMIDIAccess);
}

/**
Expand Down

0 comments on commit 8d42de2

Please sign in to comment.