Skip to content

Commit f4955c1

Browse files
Fixes window var assignment causing it to be undefined when loaded via script tag
1 parent 01ff1ca commit f4955c1

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

tuna.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,14 @@
133133
return new Tuna(context);
134134
}
135135

136-
var window = window || {};
136+
var _window = typeof window === 'undefined' ? {} : window;
137137

138-
if (!window.AudioContext) {
139-
window.AudioContext = window.webkitAudioContext;
138+
if (!_window.AudioContext) {
139+
_window.AudioContext = _window.webkitAudioContext;
140140
}
141141
if (!context) {
142142
console.log("tuna.js: Missing audio context! Creating a new context for you.");
143-
context = window.AudioContext && (new window.AudioContext());
143+
context = _window.AudioContext && (new _window.AudioContext());
144144
}
145145
if (!context) {
146146
throw new Error("Tuna cannot initialize because this environment does not support web audio.");

0 commit comments

Comments
 (0)