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/assets/javascripts/action_cable.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actioncable/app/assets/javascripts/action_cable.js') diff --git a/actioncable/app/assets/javascripts/action_cable.js b/actioncable/app/assets/javascripts/action_cable.js index a68c76f299..2b51eadb9e 100644 --- a/actioncable/app/assets/javascripts/action_cable.js +++ b/actioncable/app/assets/javascripts/action_cable.js @@ -3,8 +3,8 @@ })(this, function(exports) { "use strict"; var adapters = { - logger: window.console, - WebSocket: window.WebSocket + logger: self.console, + WebSocket: self.WebSocket }; var logger = { log: function log() { -- cgit v1.2.3