History

Sanity-check decaffeinate app.views.Content

Simon Legner committed 2 years ago

Commit 2dd04a81 parent 29b09161 file · +2 −25Browse files

Unified · Split

assets/javascripts/views/content/content.js+2−25
@@ -1,16 +1,3 @@
1// TODO: This file was created by bulk-decaffeinate.
2// Sanity-check the conversion and remove this comment.
3/*
4 * decaffeinate suggestions:
5 * DS102: Remove unnecessary code created because of implicit returns
6 * DS103: Rewrite code to no longer use __guard__, or convert again using --optional-chaining
7 * DS104: Avoid inline assignments
8 * DS204: Change includes calls to have a more natural evaluation order
9 * DS205: Consider reworking code to avoid use of IIFEs
10 * DS206: Consider reworking classes to avoid initClass
11 * DS207: Consider shorter variations of null checks
12 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
13 */
14app.views.Content = class Content extends app.View {1app.views.Content = class Content extends app.View {
15 static el = "._content";2 static el = "._content";
16 static loadingClass = "_content-loading";3 static loadingClass = "_content-loading";
@@ -229,7 +216,7 @@ app.views.Content = class Content extends app.View { · 212 unmodified lines
229 !document.activeElement ||216 !document.activeElement ||
230 !$.hasChild(this.el, document.activeElement)217 !$.hasChild(this.el, document.activeElement)
231 ) {218 ) {
232 __guard__(this.find("a:not(:empty)"), (x) => x.focus());219 this.find("a:not(:empty)")?.focus();
233 return $.stopEvent(event);220 return $.stopEvent(event);
234 }221 }
235 }222 }
@@ -251,16 +238,6 @@ app.views.Content = class Content extends app.View { · 15 unmodified lines
251 }238 }
252 239
253 isExternalUrl(url) {240 isExternalUrl(url) {
254 let needle;241 return url?.startsWith("http:") || url?.startsWith("https:");
255 return (
256 (needle = __guard__(url, (x) => x.slice(0, 6))),
257 ["http:/", "https:"].includes(needle)
258 );
259 }242 }
260};243};
261
262function __guard__(value, transform) {
263 return typeof value !== "undefined" && value !== null
264 ? transform(value)
265 : undefined;
266}