From 6dd7ea02ec98a1cbc64383dca104ecccc5b8dd07 Mon Sep 17 00:00:00 2001 From: Nicolas Ramz Date: Fri, 31 Aug 2018 13:21:01 +0200 Subject: [PATCH] Do not crash if non-prefixed AudioContext isn't available Safari 11.x only has prefixed `webAudioContext`: without this patch the polyfill crashes. --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 9a941c7..81ea36b 100644 --- a/src/index.js +++ b/src/index.js @@ -47,7 +47,7 @@ if (typeof AudioWorkletNode !== 'function') { return scriptProcessor; }; - Object.defineProperty(AudioContext.prototype, 'audioWorklet', { + Object.defineProperty((window.AudioContext||webkitAudioContext).prototype, 'audioWorklet', { get () { return this.$$audioWorklet || (this.$$audioWorklet = new window.AudioWorklet(this)); }