aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/app/assets/javascripts/action_cable.js
diff options
context:
space:
mode:
Diffstat (limited to 'actioncable/app/assets/javascripts/action_cable.js')
-rw-r--r--actioncable/app/assets/javascripts/action_cable.js17
1 files changed, 9 insertions, 8 deletions
diff --git a/actioncable/app/assets/javascripts/action_cable.js b/actioncable/app/assets/javascripts/action_cable.js
index 65e32d6c3f..a68c76f299 100644
--- a/actioncable/app/assets/javascripts/action_cable.js
+++ b/actioncable/app/assets/javascripts/action_cable.js
@@ -192,7 +192,7 @@
this.monitor.stop();
}
if (this.isActive()) {
- return this.webSocket ? this.webSocket.close() : undefined;
+ return this.webSocket.close();
}
};
Connection.prototype.reopen = function reopen() {
@@ -211,7 +211,9 @@
}
};
Connection.prototype.getProtocol = function getProtocol() {
- return this.webSocket ? this.webSocket.protocol : undefined;
+ if (this.webSocket) {
+ return this.webSocket.protocol;
+ }
};
Connection.prototype.isOpen = function isOpen() {
return this.isState("open");
@@ -452,16 +454,15 @@
};
return Consumer;
}();
- function createConsumer(url) {
- if (url == null) {
- var urlConfig = getConfig("url");
- url = urlConfig ? urlConfig : INTERNAL.default_mount_path;
- }
+ function createConsumer() {
+ var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getConfig("url") || INTERNAL.default_mount_path;
return new Consumer(createWebSocketURL(url));
}
function getConfig(name) {
var element = document.head.querySelector("meta[name='action-cable-" + name + "']");
- return element ? element.getAttribute("content") : undefined;
+ if (element) {
+ return element.getAttribute("content");
+ }
}
function createWebSocketURL(url) {
if (url && !/^wss?:/i.test(url)) {