History

ReferenceError: Must call super constructor in derived class before accessing 'this'

Simon Legner committed 2 years ago

Commit 81c05511 parent a725a0a34 files · +83 −272Browse files

Unified · Split

34 files
  1. assets/javascripts/app/db.js +7 −12
  2. assets/javascripts/app/searcher.js +3 −13
  3. assets/javascripts/app/serviceworker.js +2 −3
  4. assets/javascripts/app/update_checker.js +3 −5
  5. assets/javascripts/debug.js +1 −1
  6. assets/javascripts/lib/events.js +4 −6
  7. assets/javascripts/views/content/content.js +5 −21
  8. assets/javascripts/views/content/entry_page.js +4 −11
  9. assets/javascripts/views/content/offline_page.js +0 −5
  10. assets/javascripts/views/content/root_page.js +0 −5
  11. assets/javascripts/views/content/settings_page.js +0 −6
  12. assets/javascripts/views/layout/document.js +0 −6
  13. assets/javascripts/views/layout/menu.js +1 −6
  14. assets/javascripts/views/layout/mobile.js +10 −18
  15. assets/javascripts/views/layout/path.js +0 −6
  16. assets/javascripts/views/layout/resizer.js +0 −7
  17. assets/javascripts/views/layout/settings.js +0 −9
  18. assets/javascripts/views/list/list_focus.js +1 −8
  19. assets/javascripts/views/list/list_fold.js +1 −4
  20. assets/javascripts/views/list/list_select.js +1 −2
  21. assets/javascripts/views/misc/notif.js +3 −8
  22. assets/javascripts/views/pages/base.js +5 −4
  23. assets/javascripts/views/pages/hidden.js +1 −2
  24. assets/javascripts/views/pages/jquery.js +1 −5
  25. assets/javascripts/views/pages/sqlite.js +0 −5
  26. assets/javascripts/views/search/search.js +8 −24
  27. assets/javascripts/views/search/search_scope.js +2 −9
  28. assets/javascripts/views/sidebar/doc_list.js +2 −11
  29. assets/javascripts/views/sidebar/doc_picker.js +1 −7
  30. assets/javascripts/views/sidebar/results.js +4 −9
  31. assets/javascripts/views/sidebar/sidebar.js +8 −22
  32. assets/javascripts/views/sidebar/sidebar_hover.js +1 −9
  33. assets/javascripts/views/sidebar/type_list.js +1 −3
  34. assets/javascripts/views/view.js +3 −0
assets/javascripts/app/db.js+7−12
@@ -19,10 +19,6 @@ · 18 unmodified lines
1919 }
2020
2121 constructor() {
22− this.onOpenSuccess = this.onOpenSuccess.bind(this);
23− this.onOpenError = this.onOpenError.bind(this);
24− this.checkForCorruptedDocs = this.checkForCorruptedDocs.bind(this);
25− this.deleteCorruptedDocs = this.deleteCorruptedDocs.bind(this);
2622 this.versionMultipler = $.isIE() ? 1e5 : 1e9;
2723 this.useIndexedDB = this.useIndexedDB();
2824 this.callbacks = [];
@@ -45,9 +41,9 @@ · 16 unmodified lines
4541 NAME,
4642 VERSION * this.versionMultipler + this.userVersion(),
4743 );
48− req.onsuccess = this.onOpenSuccess;
49− req.onerror = this.onOpenError;
50− req.onupgradeneeded = this.onUpgradeNeeded;
44+ req.onsuccess = (event) => this.onOpenSuccess(event);
45+ req.onerror = (event) => this.onOpenError(event);
46+ req.onupgradeneeded = (event) => this.onUpgradeNeeded(event);
5147 } catch (error) {
5248 this.fail("exception", error);
5349 }
@@ -378,8 +374,7 @@ · 324 unmodified lines
378374
379375 load(entry, onSuccess, onError) {
380376 if (this.shouldLoadWithIDB(entry)) {
381− onError = this.loadWithXHR.bind(this, entry, onSuccess, onError);
382− return this.loadWithIDB(entry, onSuccess, onError);
377+ return this.loadWithIDB(entry, onSuccess, () => this.loadWithXHR(entry, onSuccess, onError));
383378 } else {
384379 return this.loadWithXHR(entry, onSuccess, onError);
385380 }
@@ -440,7 +435,7 @@ · 54 unmodified lines
440435 mode: "readonly",
441436 });
442437 txn.oncomplete = () => {
443− setTimeout(this.checkForCorruptedDocs, 50);
438+ setTimeout(() => this.checkForCorruptedDocs(), 50);
444439 };
445440
446441 const req = txn.objectStore("docs").openCursor();
@@ -486,7 +481,7 @@ · 39 unmodified lines
486481 }
487482
488483 if (docs.length === 0) {
489− setTimeout(this.deleteCorruptedDocs, 0);
484+ setTimeout(() => this.deleteCorruptedDocs(), 0);
490485 return;
491486 }
492487
@@ -497,7 +492,7 @@ · 4 unmodified lines
497492 });
498493 txn.oncomplete = () => {
499494 if (this.corruptedDocs.length > 0) {
500− setTimeout(this.deleteCorruptedDocs, 0);
495+ setTimeout(() => this.deleteCorruptedDocs(), 0);
501496 }
502497 };
503498
assets/javascripts/app/searcher.js+3−13
@@ -215,12 +215,7 @@ function scoreFuzzyMatch() { · 214 unmodified lines
215215 }
216216
217217 constructor(options) {
218− this.match = this.match.bind(this);
219− this.matchChunks = this.matchChunks.bind(this);
220− if (options == null) {
221− options = {};
222− }
223− this.options = $.extend({}, DEFAULTS, options);
218+ this.options = $.extend({}, DEFAULTS, options || {});
224219 }
225220
226221 find(data, attr, q) {
@@ -307,10 +302,10 @@ function scoreFuzzyMatch() { · 80 unmodified lines
307302 this.matchChunk();
308303
309304 if (this.cursor === this.dataLength || this.scoredEnough()) {
310− this.delay(this.match);
305+ this.delay(() => this.match());
311306 this.sendResults();
312307 } else {
313− this.delay(this.matchChunks);
308+ this.delay(() => this.matchChunks());
314309 }
315310 }
316311
@@ -410,11 +405,6 @@ function scoreFuzzyMatch() { · 93 unmodified lines
410405 })();
411406
412407 app.SynchronousSearcher = class SynchronousSearcher extends app.Searcher {
413− constructor(...args) {
414− this.match = this.match.bind(this);
415− super(...args);
416− }
417−
418408 match() {
419409 if (this.matcher) {
420410 if (!this.allResults) {
assets/javascripts/app/serviceworker.js+2−3
@@ -16,7 +16,6 @@ app.ServiceWorker = class ServiceWorker { · 15 unmodified lines
1616 }
1717
1818 constructor() {
19− this.onUpdateFound = this.onUpdateFound.bind(this);
2019 this.onStateChange = this.onStateChange.bind(this);
2120 this.registration = null;
2221 this.notifyUpdate = true;
@@ -51,12 +50,12 @@ app.ServiceWorker = class ServiceWorker { · 28 unmodified lines
5150
5251 updateRegistration(registration) {
5352 this.registration = registration;
54− $.on(this.registration, "updatefound", this.onUpdateFound);
53+ $.on(this.registration, "updatefound", () => this.onUpdateFound());
5554 }
5655
5756 onUpdateFound() {
5857 if (this.installingRegistration) {
59− $.off(this.installingRegistration, "statechange", this.onStateChange());
58+ $.off(this.installingRegistration, "statechange", this.onStateChange);
6059 }
6160 this.installingRegistration = this.registration.installing;
6261 $.on(this.installingRegistration, "statechange", this.onStateChange);
assets/javascripts/app/update_checker.js+3−5
@@ -7,16 +7,14 @@ · 6 unmodified lines
77 */
88 app.UpdateChecker = class UpdateChecker {
99 constructor() {
10− this.checkDocs = this.checkDocs.bind(this);
11− this.onFocus = this.onFocus.bind(this);
1210 this.lastCheck = Date.now();
1311
14− $.on(window, "focus", this.onFocus);
12+ $.on(window, "focus", () => this.onFocus());
1513 if (app.serviceWorker != null) {
16− app.serviceWorker.on("updateready", this.onUpdateReady);
14+ app.serviceWorker.on("updateready", () => this.onUpdateReady());
1715 }
1816
19− setTimeout(this.checkDocs, 0);
17+ setTimeout(() => this.checkDocs(), 0);
2018 }
2119
2220 check() {
assets/javascripts/debug.js+1−1
@@ -110,7 +110,7 @@ this.viewTree = function (view, level, visited) { · 109 unmodified lines
110110 `%c ${Array(level + 1).join(" ")}${
111111 view.constructor.name
112112 }: ${!!view.activated}`,
113− "color:" + ((view.activated && "green") || "red")
113+ "color:" + ((view.activated && "green") || "red"),
114114 );
115115
116116 for (var key of Object.keys(view || {})) {
assets/javascripts/lib/events.js+4−6
@@ -48,14 +48,12 @@ class Events { · 47 unmodified lines
4848 }
4949
5050 trigger(event, ...args) {
51− let callbacks;
5251 this.eventInProgress = { name: event, args };
53− if (
54− (callbacks = this._callbacks != null ? this._callbacks[event] : undefined)
55− ) {
56− for (var callback of Array.from(callbacks.slice(0))) {
52+ const callbacks = this._callbacks?.[event];
53+ if (callbacks) {
54+ for (let callback of Array.from(callbacks.slice(0))) {
5755 if (typeof callback === "function") {
58− callback(...Array.from(args || []));
56+ callback(...args);
5957 }
6058 }
6159 }
assets/javascripts/views/content/content.js+5−21
@@ -13,24 +13,6 @@ · 12 unmodified lines
1313 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
1414 */
1515 app.views.Content = class Content extends app.View {
16− constructor(...args) {
17− this.scrollToTop = this.scrollToTop.bind(this);
18− this.scrollToBottom = this.scrollToBottom.bind(this);
19− this.scrollStepUp = this.scrollStepUp.bind(this);
20− this.scrollStepDown = this.scrollStepDown.bind(this);
21− this.scrollPageUp = this.scrollPageUp.bind(this);
22− this.scrollPageDown = this.scrollPageDown.bind(this);
23− this.onReady = this.onReady.bind(this);
24− this.onBootError = this.onBootError.bind(this);
25− this.onEntryLoading = this.onEntryLoading.bind(this);
26− this.onEntryLoaded = this.onEntryLoaded.bind(this);
27− this.beforeRoute = this.beforeRoute.bind(this);
28− this.afterRoute = this.afterRoute.bind(this);
29− this.onClick = this.onClick.bind(this);
30− this.onAltF = this.onAltF.bind(this);
31− super(...args);
32− }
33−
3416 static initClass() {
3517 this.el = "._content";
3618 this.loadingClass = "_content-loading";
@@ -68,10 +50,12 @@ app.views.Content = class Content extends app.View { · 31 unmodified lines
6850 this.entryPage = new app.views.EntryPage();
6951
7052 this.entryPage
71− .on("loading", this.onEntryLoading)
72− .on("loaded", this.onEntryLoaded);
53+ .on("loading", () => this.onEntryLoading())
54+ .on("loaded", () => this.onEntryLoaded());
7355
74− app.on("ready", this.onReady).on("bootError", this.onBootError);
56+ app
57+ .on("ready", () => this.onReady())
58+ .on("bootError", () => this.onBootError());
7559 }
7660
7761 show(view) {
assets/javascripts/views/content/entry_page.js+4−11
@@ -13,16 +13,6 @@ · 12 unmodified lines
1313 (function () {
1414 let LINKS = undefined;
1515 app.views.EntryPage = class EntryPage extends app.View {
16− constructor(...args) {
17− this.beforeRoute = this.beforeRoute.bind(this);
18− this.onSuccess = this.onSuccess.bind(this);
19− this.onError = this.onError.bind(this);
20− this.onClick = this.onClick.bind(this);
21− this.onAltC = this.onAltC.bind(this);
22− this.onAltO = this.onAltO.bind(this);
23− super(...args);
24− }
25−
2616 static initClass() {
2717 this.className = "_page";
2818 this.errorClass = "_page-error";
@@ -182,7 +172,10 @@ · 153 unmodified lines
182172
183173 load() {
184174 this.loading();
185− this.xhr = this.entry.loadFile(this.onSuccess, this.onError);
175+ this.xhr = this.entry.loadFile(
176+ (response) => this.onSuccess(response),
177+ () => this.onError(),
178+ );
186179 }
187180
188181 abort() {
assets/javascripts/views/content/offline_page.js+0−5
@@ -9,11 +9,6 @@ · 8 unmodified lines
99 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
1010 */
1111 app.views.OfflinePage = class OfflinePage extends app.View {
12− constructor(...args) {
13− this.onClick = this.onClick.bind(this);
14− super(...args);
15− }
16−
1712 static initClass() {
1813 this.className = "_static";
1914
assets/javascripts/views/content/root_page.js+0−5
@@ -8,11 +8,6 @@ · 7 unmodified lines
88 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
99 */
1010 app.views.RootPage = class RootPage extends app.View {
11− constructor(...args) {
12− this.onClick = this.onClick.bind(this);
13− super(...args);
14− }
15−
1611 static initClass() {
1712 this.events = { click: "onClick" };
1813 }
assets/javascripts/views/content/settings_page.js+0−6
@@ -10,12 +10,6 @@ · 9 unmodified lines
1010 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
1111 */
1212 app.views.SettingsPage = class SettingsPage extends app.View {
13− constructor(...args) {
14− this.onChange = this.onChange.bind(this);
15− this.onClick = this.onClick.bind(this);
16− super(...args);
17− }
18−
1913 static initClass() {
2014 this.className = "_static";
2115
assets/javascripts/views/layout/document.js+0−6
@@ -9,12 +9,6 @@ · 8 unmodified lines
99 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
1010 */
1111 app.views.Document = class Document extends app.View {
12− constructor(...args) {
13− this.afterRoute = this.afterRoute.bind(this);
14− this.onVisibilityChange = this.onVisibilityChange.bind(this);
15− super(...args);
16− }
17−
1812 static initClass() {
1913 this.el = document;
2014
assets/javascripts/views/layout/menu.js+1−6
@@ -7,11 +7,6 @@ · 6 unmodified lines
77 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
88 */
99 app.views.Menu = class Menu extends app.View {
10− constructor(...args) {
11− this.onGlobalClick = this.onGlobalClick.bind(this);
12− super(...args);
13− }
14−
1510 static initClass() {
1611 this.el = "._menu";
1712 this.activeClass = "active";
@@ -20,7 +15,7 @@ app.views.Menu = class Menu extends app.View { · 2 unmodified lines
2015 }
2116
2217 init() {
23− $.on(document.body, "click", this.onGlobalClick);
18+ $.on(document.body, "click", (event) => this.onGlobalClick(event));
2419 }
2520
2621 onClick(event) {
assets/javascripts/views/layout/mobile.js+10−18
@@ -54,44 +54,36 @@ app.views.Mobile = class Mobile extends app.View { · 53 unmodified lines
5454 }
5555
5656 constructor() {
57− this.showSidebar = this.showSidebar.bind(this);
58− this.hideSidebar = this.hideSidebar.bind(this);
59− this.onClickBack = this.onClickBack.bind(this);
60− this.onClickForward = this.onClickForward.bind(this);
61− this.onClickToggleSidebar = this.onClickToggleSidebar.bind(this);
62− this.onClickDocPickerTab = this.onClickDocPickerTab.bind(this);
63− this.onClickSettingsTab = this.onClickSettingsTab.bind(this);
64− this.onTapSearch = this.onTapSearch.bind(this);
65− this.onEscape = this.onEscape.bind(this);
66− this.afterRoute = this.afterRoute.bind(this);
67− this.el = document.documentElement;
6857 super(...arguments);
58+ this.el = document.documentElement;
6959 }
7060
7161 init() {
72− $.on($("._search"), "touchend", this.onTapSearch);
62+ $.on($("._search"), "touchend", () => this.onTapSearch());
7363
7464 this.toggleSidebar = $("button[data-toggle-sidebar]");
7565 this.toggleSidebar.removeAttribute("hidden");
76− $.on(this.toggleSidebar, "click", this.onClickToggleSidebar);
66+ $.on(this.toggleSidebar, "click", () => this.onClickToggleSidebar());
7767
7868 this.back = $("button[data-back]");
7969 this.back.removeAttribute("hidden");
80− $.on(this.back, "click", this.onClickBack);
70+ $.on(this.back, "click", () => this.onClickBack());
8171
8272 this.forward = $("button[data-forward]");
8373 this.forward.removeAttribute("hidden");
84− $.on(this.forward, "click", this.onClickForward);
74+ $.on(this.forward, "click", () => this.onClickForward());
8575
8676 this.docPickerTab = $('button[data-tab="doc-picker"]');
8777 this.docPickerTab.removeAttribute("hidden");
88− $.on(this.docPickerTab, "click", this.onClickDocPickerTab);
78+ $.on(this.docPickerTab, "click", (event) =>
79+ this.onClickDocPickerTab(event),
80+ );
8981
9082 this.settingsTab = $('button[data-tab="settings"]');
9183 this.settingsTab.removeAttribute("hidden");
92− $.on(this.settingsTab, "click", this.onClickSettingsTab);
84+ $.on(this.settingsTab, "click", (event) => this.onClickSettingsTab(event));
9385
94− app.document.sidebar.search.on("searching", this.showSidebar);
86+ app.document.sidebar.search.on("searching", () => this.showSidebar());
9587
9688 this.activate();
9789 }
assets/javascripts/views/layout/path.js+0−6
@@ -8,12 +8,6 @@ · 7 unmodified lines
88 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
99 */
1010 app.views.Path = class Path extends app.View {
11− constructor(...args) {
12− this.onClick = this.onClick.bind(this);
13− this.afterRoute = this.afterRoute.bind(this);
14− super(...args);
15− }
16−
1711 static initClass() {
1812 this.className = "_path";
1913 this.attributes = { role: "complementary" };
assets/javascripts/views/layout/resizer.js+0−7
@@ -11,13 +11,6 @@ · 10 unmodified lines
1111 let MIN = undefined;
1212 let MAX = undefined;
1313 app.views.Resizer = class Resizer extends app.View {
14− constructor(...args) {
15− this.onDragStart = this.onDragStart.bind(this);
16− this.onDrag = this.onDrag.bind(this);
17− this.onDragEnd = this.onDragEnd.bind(this);
18− super(...args);
19− }
20−
2114 static initClass() {
2215 this.className = "_resizer";
2316
assets/javascripts/views/layout/settings.js+0−9
@@ -13,15 +13,6 @@ · 12 unmodified lines
1313 (function () {
1414 let SIDEBAR_HIDDEN_LAYOUT = undefined;
1515 app.views.Settings = class Settings extends app.View {
16− constructor(...args) {
17− this.onChange = this.onChange.bind(this);
18− this.onEnter = this.onEnter.bind(this);
19− this.onSubmit = this.onSubmit.bind(this);
20− this.onImport = this.onImport.bind(this);
21− this.onClick = this.onClick.bind(this);
22− super(...args);
23− }
24−
2516 static initClass() {
2617 SIDEBAR_HIDDEN_LAYOUT = "_sidebar-hidden";
2718
assets/javascripts/views/list/list_focus.js+1−8
@@ -25,15 +25,8 @@ app.views.ListFocus = class ListFocus extends app.View { · 24 unmodified lines
2525 }
2626
2727 constructor(el) {
28− this.blur = this.blur.bind(this);
29− this.onDown = this.onDown.bind(this);
30− this.onUp = this.onUp.bind(this);
31− this.onLeft = this.onLeft.bind(this);
32− this.onEnter = this.onEnter.bind(this);
33− this.onSuperEnter = this.onSuperEnter.bind(this);
34− this.onClick = this.onClick.bind(this);
35− this.el = el;
3628 super(...arguments);
29+ this.el = el;
3730 this.focusOnNextFrame = $.framify(this.focus, this);
3831 }
3932
assets/javascripts/views/list/list_fold.js+1−4
@@ -23,11 +23,8 @@ app.views.ListFold = class ListFold extends app.View { · 22 unmodified lines
2323 }
2424
2525 constructor(el) {
26− this.onLeft = this.onLeft.bind(this);
27− this.onRight = this.onRight.bind(this);
28− this.onClick = this.onClick.bind(this);
29− this.el = el;
3026 super(...arguments);
27+ this.el = el;
3128 }
3229
3330 open(el) {
assets/javascripts/views/list/list_select.js+1−2
@@ -16,9 +16,8 @@ app.views.ListSelect = class ListSelect extends app.View { · 15 unmodified lines
1616 }
1717
1818 constructor(el) {
19− this.onClick = this.onClick.bind(this);
20− this.el = el;
2119 super(...arguments);
20+ this.el = el;
2221 }
2322
2423 deactivate() {
assets/javascripts/views/misc/notif.js+3−8
@@ -13,20 +13,15 @@ app.views.Notif = class Notif extends app.View { · 12 unmodified lines
1313 this.activeClass = "_in";
1414 this.attributes = { role: "alert" };
1515
16− this.defautOptions = { autoHide: 15000 };
16+ this.defaultOptions = { autoHide: 15000 };
1717
1818 this.events = { click: "onClick" };
1919 }
2020
2121 constructor(type, options) {
22− this.onClick = this.onClick.bind(this);
23− this.type = type;
24− if (options == null) {
25− options = {};
26− }
27− this.options = options;
28− this.options = $.extend({}, this.constructor.defautOptions, this.options);
2922 super(...arguments);
23+ this.type = type;
24+ this.options = $.extend({}, this.constructor.defaultOptions, options || {});
3025 }
3126
3227 init() {
assets/javascripts/views/pages/base.js+5−4
@@ -10,10 +10,9 @@ · 9 unmodified lines
1010 */
1111 app.views.BasePage = class BasePage extends app.View {
1212 constructor(el, entry) {
13− this.paintCode = this.paintCode.bind(this);
13+ super(...arguments);
1414 this.el = el;
1515 this.entry = entry;
16− super(...arguments);
1716 }
1817
1918 deactivate() {
@@ -40,7 +39,9 @@ app.views.BasePage = class BasePage extends app.View { · 20 unmodified lines
4039 this.delay(this.afterRender);
4140 }
4241 if (this.highlightNodes.length > 0) {
43− $.requestAnimationFrame(() => $.requestAnimationFrame(this.paintCode));
42+ $.requestAnimationFrame(() =>
43+ $.requestAnimationFrame(() => this.paintCode()),
44+ );
4445 }
4546 }
4647
@@ -80,7 +81,7 @@ app.views.BasePage = class BasePage extends app.View { · 33 unmodified lines
8081 }
8182
8283 if (this.highlightNodes.length > 0) {
83− $.requestAnimationFrame(this.paintCode);
84+ $.requestAnimationFrame(() => this.paintCode());
8485 }
8586 this.previousTiming = timing;
8687 }
assets/javascripts/views/pages/hidden.js+1−2
@@ -12,10 +12,9 @@ app.views.HiddenPage = class HiddenPage extends app.View { · 11 unmodified lines
1212 }
1313
1414 constructor(el, entry) {
15− this.onClick = this.onClick.bind(this);
15+ super(...arguments);
1616 this.el = el;
1717 this.entry = entry;
18− super(...arguments);
1918 }
2019
2120 init() {
assets/javascripts/views/pages/jquery.js+1−5
@@ -11,11 +11,6 @@ · 10 unmodified lines
1111 //= require views/pages/base
1212
1313 app.views.JqueryPage = class JqueryPage extends app.views.BasePage {
14− constructor(...args) {
15− this.onIframeLoaded = this.onIframeLoaded.bind(this);
16− super(...args);
17− }
18−
1914 static initClass() {
2015 this.demoClassName = "_jquery-demo";
2116 }
@@ -24,6 +19,7 @@ app.views.JqueryPage = class JqueryPage extends app.views.BasePage { · 2 unmodified lines
2419 // Prevent jQuery Mobile's demo iframes from scrolling the page
2520 for (var iframe of Array.from(this.findAllByTag("iframe"))) {
2621 iframe.style.display = "none";
22+ this.onIframeLoaded = this.onIframeLoaded.bind(this);
2723 $.on(iframe, "load", this.onIframeLoaded);
2824 }
2925
assets/javascripts/views/pages/sqlite.js+0−5
@@ -9,11 +9,6 @@ · 8 unmodified lines
99 //= require views/pages/base
1010
1111 app.views.SqlitePage = class SqlitePage extends app.views.BasePage {
12− constructor(...args) {
13− this.onClick = this.onClick.bind(this);
14− super(...args);
15− }
16−
1712 static initClass() {
1813 this.events = { click: "onClick" };
1914 }
assets/javascripts/views/search/search.js+8−24
@@ -13,24 +13,6 @@ · 12 unmodified lines
1313 let SEARCH_PARAM = undefined;
1414 let HASH_RGX = undefined;
1515 app.views.Search = class Search extends app.View {
16− constructor(...args) {
17− this.focus = this.focus.bind(this);
18− this.autoFocus = this.autoFocus.bind(this);
19− this.onWindowFocus = this.onWindowFocus.bind(this);
20− this.onReady = this.onReady.bind(this);
21− this.onInput = this.onInput.bind(this);
22− this.searchUrl = this.searchUrl.bind(this);
23− this.google = this.google.bind(this);
24− this.stackoverflow = this.stackoverflow.bind(this);
25− this.duckduckgo = this.duckduckgo.bind(this);
26− this.onResults = this.onResults.bind(this);
27− this.onEnd = this.onEnd.bind(this);
28− this.onClick = this.onClick.bind(this);
29− this.onScopeChange = this.onScopeChange.bind(this);
30− this.afterRoute = this.afterRoute.bind(this);
31− super(...args);
32− }
33−
3416 static initClass() {
3517 SEARCH_PARAM = app.config.search_param;
3618
@@ -64,13 +46,15 @@ · 27 unmodified lines
6446 this.addSubview((this.scope = new app.views.SearchScope(this.el)));
6547
6648 this.searcher = new app.Searcher();
67− this.searcher.on("results", this.onResults).on("end", this.onEnd);
49+ this.searcher
50+ .on("results", (results) => this.onResults(results))
51+ .on("end", () => this.onEnd());
6852
69− this.scope.on("change", this.onScopeChange);
53+ this.scope.on("change", () => this.onScopeChange());
7054
71− app.on("ready", this.onReady);
72− $.on(window, "hashchange", this.searchUrl);
73− $.on(window, "focus", this.onWindowFocus);
55+ app.on("ready", () => this.onReady());
56+ $.on(window, "hashchange", () => this.searchUrl());
57+ $.on(window, "focus", (event) => this.onWindowFocus(event));
7458 }
7559
7660 focus() {
@@ -247,7 +231,7 @@ · 170 unmodified lines
247231 if (context.hash) {
248232 this.delay(this.searchUrl);
249233 }
250− $.requestAnimationFrame(this.autoFocus);
234+ $.requestAnimationFrame(() => this.autoFocus());
251235 }
252236
253237 extractHashValue() {
assets/javascripts/views/search/search_scope.js+2−9
@@ -33,15 +33,8 @@ · 32 unmodified lines
3333 }
3434
3535 constructor(el) {
36− this.onResults = this.onResults.bind(this);
37− this.reset = this.reset.bind(this);
38− this.doScopeSearch = this.doScopeSearch.bind(this);
39− this.onClick = this.onClick.bind(this);
40− this.onKeydown = this.onKeydown.bind(this);
41− this.onTextInput = this.onTextInput.bind(this);
42− this.afterRoute = this.afterRoute.bind(this);
43− this.el = el;
4436 super(...arguments);
37+ this.el = el;
4538 }
4639
4740 init() {
@@ -51,7 +44,7 @@ · 3 unmodified lines
5144 fuzzy_min_length: 2,
5245 max_results: 1,
5346 });
54− this.searcher.on("results", this.onResults);
47+ this.searcher.on("results", (results) => this.onResults(results));
5548 }
5649
5750 getScope() {
assets/javascripts/views/sidebar/doc_list.js+2−11
@@ -9,16 +9,6 @@ · 8 unmodified lines
99 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
1010 */
1111 app.views.DocList = class DocList extends app.View {
12− constructor(...args) {
13− this.render = this.render.bind(this);
14− this.onOpen = this.onOpen.bind(this);
15− this.onClose = this.onClose.bind(this);
16− this.onClick = this.onClick.bind(this);
17− this.onEnabled = this.onEnabled.bind(this);
18− this.afterRoute = this.afterRoute.bind(this);
19− super(...args);
20− }
21−
2212 static initClass() {
2313 this.className = "_list";
2414 this.attributes = { role: "navigation" };
@@ -44,7 +34,7 @@ app.views.DocList = class DocList extends app.View { · 19 unmodified lines
4434 this.addSubview((this.listFold = new app.views.ListFold(this.el)));
4535 this.addSubview((this.listSelect = new app.views.ListSelect(this.el)));
4636
47− app.on("ready", this.render);
37+ app.on("ready", () => this.render());
4838 }
4939
5040 activate() {
@@ -248,6 +238,7 @@ app.views.DocList = class DocList extends app.View { · 197 unmodified lines
248238 $.stopEvent(event);
249239 const doc = app.disabledDocs.findBy("slug", slug);
250240 if (doc) {
241+ this.onEnabled = this.onEnabled.bind(this);
251242 app.enableDoc(doc, this.onEnabled, this.onEnabled);
252243 }
253244 }
assets/javascripts/views/sidebar/doc_picker.js+1−7
@@ -11,13 +11,6 @@ · 10 unmodified lines
1111 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
1212 */
1313 app.views.DocPicker = class DocPicker extends app.View {
14− constructor(...args) {
15− this.onMouseDown = this.onMouseDown.bind(this);
16− this.onMouseUp = this.onMouseUp.bind(this);
17− this.onDOMFocus = this.onDOMFocus.bind(this);
18− super(...args);
19− }
20−
2114 static initClass() {
2215 this.className = "_list _list-picker";
2316
@@ -34,6 +27,7 @@ app.views.DocPicker = class DocPicker extends app.View { · 10 unmodified lines
3427 activate() {
3528 if (super.activate(...arguments)) {
3629 this.render();
30+ this.onDOMFocus = this.onDOMFocus.bind(this);
3731 $.on(this.el, "focus", this.onDOMFocus, true);
3832 }
3933 }
assets/javascripts/views/sidebar/results.js+4−9
@@ -18,14 +18,9 @@ app.views.Results = class Results extends app.View { · 17 unmodified lines
1818 }
1919
2020 constructor(sidebar, search) {
21− this.onResults = this.onResults.bind(this);
22− this.onNoResults = this.onNoResults.bind(this);
23− this.onClear = this.onClear.bind(this);
24− this.afterRoute = this.afterRoute.bind(this);
25− this.onClick = this.onClick.bind(this);
21+ super(...arguments);
2622 this.sidebar = sidebar;
2723 this.search = search;
28− super(...arguments);
2924 }
3025
3126 deactivate() {
@@ -39,9 +34,9 @@ app.views.Results = class Results extends app.View { · 7 unmodified lines
3934 this.addSubview((this.listSelect = new app.views.ListSelect(this.el)));
4035
4136 this.search
42− .on("results", this.onResults)
43− .on("noresults", this.onNoResults)
44− .on("clear", this.onClear);
37+ .on("results", (entries, flags) => this.onResults(entries, flags))
38+ .on("noresults", () => this.onNoResults())
39+ .on("clear", () => this.onClear());
4540 }
4641
4742 onResults(entries, flags) {
assets/javascripts/views/sidebar/sidebar.js+8−22
@@ -10,23 +10,6 @@ · 9 unmodified lines
1010 * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
1111 */
1212 app.views.Sidebar = class Sidebar extends app.View {
13− constructor(...args) {
14− this.resetHoverOnMouseMove = this.resetHoverOnMouseMove.bind(this);
15− this.resetHover = this.resetHover.bind(this);
16− this.showResults = this.showResults.bind(this);
17− this.onReady = this.onReady.bind(this);
18− this.onScopeChange = this.onScopeChange.bind(this);
19− this.onSearching = this.onSearching.bind(this);
20− this.onSearchClear = this.onSearchClear.bind(this);
21− this.onFocus = this.onFocus.bind(this);
22− this.onSelect = this.onSelect.bind(this);
23− this.onClick = this.onClick.bind(this);
24− this.onAltR = this.onAltR.bind(this);
25− this.onEscape = this.onEscape.bind(this);
26− this.afterRoute = this.afterRoute.bind(this);
27− super(...args);
28− }
29−
3013 static initClass() {
3114 this.el = "._sidebar";
3215
@@ -51,14 +34,16 @@ app.views.Sidebar = class Sidebar extends app.View { · 18 unmodified lines
5134 this.addSubview((this.search = new app.views.Search()));
5235
5336 this.search
54− .on("searching", this.onSearching)
55− .on("clear", this.onSearchClear)
56− .scope.on("change", this.onScopeChange);
37+ .on("searching", () => this.onSearching())
38+ .on("clear", () => this.onSearchClear())
39+ .scope.on("change", (newDoc, previousDoc) =>
40+ this.onScopeChange((newDoc, previousDoc)),
41+ );
5742
5843 this.results = new app.views.Results(this, this.search);
5944 this.docList = new app.views.DocList();
6045
61− app.on("ready", this.onReady);
46+ app.on("ready", () => this.onReady());
6247
6348 $.on(document.documentElement, "mouseleave", () => this.hide());
6449 $.on(document.documentElement, "mouseenter", () =>
@@ -85,13 +70,14 @@ app.views.Sidebar = class Sidebar extends app.View { · 20 unmodified lines
8570
8671 if (options.forceNoHover !== false && !this.hasClass("no-hover")) {
8772 this.addClass("no-hover");
73+ this.resetHoverOnMouseMove = this.resetHoverOnMouseMove.bind(this);
8874 $.on(window, "mousemove", this.resetHoverOnMouseMove);
8975 }
9076 }
9177
9278 resetHoverOnMouseMove() {
9379 $.off(window, "mousemove", this.resetHoverOnMouseMove);
94− return $.requestAnimationFrame(this.resetHover);
80+ return $.requestAnimationFrame(() => this.resetHover());
9581 }
9682
9783 resetHover() {
assets/javascripts/views/sidebar/sidebar_hover.js+1−9
@@ -26,19 +26,11 @@ app.views.SidebarHover = class SidebarHover extends app.View { · 25 unmodified lines
2626 }
2727
2828 constructor(el) {
29− this.position = this.position.bind(this);
30− this.onFocus = this.onFocus.bind(this);
31− this.onBlur = this.onBlur.bind(this);
32− this.onMouseover = this.onMouseover.bind(this);
33− this.onMouseout = this.onMouseout.bind(this);
34− this.onScroll = this.onScroll.bind(this);
35− this.onClick = this.onClick.bind(this);
36− this.onRoute = this.onRoute.bind(this);
29+ super(...arguments);
3730 this.el = el;
3831 if (!isPointerEventsSupported()) {
3932 delete this.constructor.events.mouseover;
4033 }
41− super(...arguments);
4234 }
4335
4436 show(el) {
assets/javascripts/views/sidebar/type_list.js+1−3
@@ -21,10 +21,8 @@ app.views.TypeList = class TypeList extends app.View { · 20 unmodified lines
2121 }
2222
2323 constructor(doc) {
24− this.onOpen = this.onOpen.bind(this);
25− this.onClose = this.onClose.bind(this);
26− this.doc = doc;
2724 super(...arguments);
25+ this.doc = doc;
2826 }
2927
3028 init() {
assets/javascripts/views/view.js+3−0
@@ -174,6 +174,7 @@ app.View = class View { · 173 unmodified lines
174174 if (this.constructor.events) {
175175 for (name in this.constructor.events) {
176176 method = this.constructor.events[name];
177+ this[method] = this[method].bind(this);
177178 this.onDOM(name, this[method]);
178179 }
179180 }
@@ -181,6 +182,7 @@ app.View = class View { · 1 unmodified line
181182 if (this.constructor.routes) {
182183 for (name in this.constructor.routes) {
183184 method = this.constructor.routes[name];
185+ this[method] = this[method].bind(this);
184186 app.router.on(name, this[method]);
185187 }
186188 }
@@ -188,6 +190,7 @@ app.View = class View { · 1 unmodified line
188190 if (this.constructor.shortcuts) {
189191 for (name in this.constructor.shortcuts) {
190192 method = this.constructor.shortcuts[name];
193+ this[method] = this[method].bind(this);
191194 app.shortcuts.on(name, this[method]);
192195 }
193196 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t