Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify WebMIDI detection #190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Commits on Jul 27, 2016

  1. Simplify WebMIDI detection

    The previous code is broken: the result of indexOf is an index, and -1 if
    the searched string is not found.  So the value will be non-zero (and
    therefore thuthy) in all realistic setups, making the plugin enumeration an
    unused code branch.
    
    We COULD fix the intent of the original code, by comparing the indexOf
    result against -1.  But doing so would break systems where WebMIDI is
    provided by some other plugin or polyfill, where plugins cannot be
    enumerated, where native functions stringify in some other way, where
    something monkey-patched the method in question, or something like that.
    
    So instead this commit here relies on the ducktyping philosophy: if there is
    a navigator.requestMIDIAccess method, we assume it does the right thing and
    avoid further checks.  This is what the current code is essentially doing
    right now anyway, even though not intentionally.
    gagern committed Jul 27, 2016
    Configuration menu
    Copy the full SHA
    7e5d440 View commit details
    Browse the repository at this point in the history