From ac8ffbe76a90d89a5655bea6af5abcac6c7320e0 Mon Sep 17 00:00:00 2001 From: Richard Macklin Date: Thu, 18 Oct 2018 22:00:06 -0700 Subject: Replace `window` references in ActionCable with `self` Before this change, attempting to use ActionCable inside a web worker would result in an exception being thrown: ``` ReferenceError: window is not defined ``` By replacing the `window` reference with `self`, which is available in both a window context and a worker context, we can avoid this error. Ref: https://developer.mozilla.org/en-US/docs/Web/API/Window/self --- actioncable/app/javascript/action_cable/adapters.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actioncable/app/javascript/action_cable/adapters.js') diff --git a/actioncable/app/javascript/action_cable/adapters.js b/actioncable/app/javascript/action_cable/adapters.js index 9ba6d338ee..4de8131438 100644 --- a/actioncable/app/javascript/action_cable/adapters.js +++ b/actioncable/app/javascript/action_cable/adapters.js @@ -1,4 +1,4 @@ export default { - logger: window.console, - WebSocket: window.WebSocket + logger: self.console, + WebSocket: self.WebSocket } -- cgit v1.2.3