aboutsummaryrefslogtreecommitdiffstats
path: root/actioncable/app/assets/javascripts/action_cable.js
diff options
context:
space:
mode:
authorRichard Macklin <richard.github@nrm.com>2019-01-14 11:35:04 -0800
committerRichard Macklin <richard.github@nrm.com>2019-01-14 11:35:04 -0800
commit6320916513891938f7d2f0b5c9c36968ee2d8705 (patch)
tree986965d8b9eb7cd3b0592dad07fd7b31e56a3ba2 /actioncable/app/assets/javascripts/action_cable.js
parentdbe073aebf198493a1a162d314c49dfcd5dbbf1b (diff)
downloadrails-6320916513891938f7d2f0b5c9c36968ee2d8705.tar.gz
rails-6320916513891938f7d2f0b5c9c36968ee2d8705.tar.bz2
rails-6320916513891938f7d2f0b5c9c36968ee2d8705.zip
Simplify ActionCable.getConfig, Connection#getProtocol, and Connection#close
by relying on the implicit undefined return value
Diffstat (limited to 'actioncable/app/assets/javascripts/action_cable.js')
-rw-r--r--actioncable/app/assets/javascripts/action_cable.js12
1 files changed, 8 insertions, 4 deletions
diff --git a/actioncable/app/assets/javascripts/action_cable.js b/actioncable/app/assets/javascripts/action_cable.js
index 7710313c40..d860fba76e 100644
--- a/actioncable/app/assets/javascripts/action_cable.js
+++ b/actioncable/app/assets/javascripts/action_cable.js
@@ -191,8 +191,8 @@
if (!allowReconnect) {
this.monitor.stop();
}
- if (this.isActive()) {
- return this.webSocket ? this.webSocket.close() : undefined;
+ if (this.isActive() && this.webSocket) {
+ 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");
@@ -458,7 +460,9 @@
}
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)) {