mirror of https://github.com/rails/rails
Simplify ActionCable.getConfig, Connection#getProtocol, and Connection#close
by relying on the implicit undefined return value
This commit is contained in:
parent
dbe073aebf
commit
6320916513
|
@ -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)) {
|
||||
|
|
|
@ -44,7 +44,9 @@ class Connection {
|
|||
|
||||
close({allowReconnect} = {allowReconnect: true}) {
|
||||
if (!allowReconnect) { this.monitor.stop() }
|
||||
if (this.isActive()) { return (this.webSocket ? this.webSocket.close() : undefined) }
|
||||
if (this.isActive() && this.webSocket) {
|
||||
return this.webSocket.close()
|
||||
}
|
||||
}
|
||||
|
||||
reopen() {
|
||||
|
@ -65,7 +67,9 @@ class Connection {
|
|||
}
|
||||
|
||||
getProtocol() {
|
||||
return (this.webSocket ? this.webSocket.protocol : undefined)
|
||||
if (this.webSocket) {
|
||||
return this.webSocket.protocol
|
||||
}
|
||||
}
|
||||
|
||||
isOpen() {
|
||||
|
|
|
@ -24,7 +24,9 @@ export function createConsumer(url = getConfig("url") || INTERNAL.default_mount_
|
|||
|
||||
export function getConfig(name) {
|
||||
const element = document.head.querySelector(`meta[name='action-cable-${name}']`)
|
||||
return (element ? element.getAttribute("content") : undefined)
|
||||
if (element) {
|
||||
return element.getAttribute("content")
|
||||
}
|
||||
}
|
||||
|
||||
export function createWebSocketURL(url) {
|
||||
|
|
Loading…
Reference in New Issue