From: Tim Düsterhus Date: Thu, 29 Oct 2020 13:41:49 +0000 (+0100) Subject: Clean up code style and types for existing TypeScript modules X-Git-Tag: 5.4.0_Alpha_1~689^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=8ef61d386961656dc03cc0598bf6f662b0bd1127;p=GitHub%2FWoltLab%2FWCF.git Clean up code style and types for existing TypeScript modules --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Jsonp.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Jsonp.js index 571c7f60b8..dc2bae753e 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Jsonp.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Jsonp.js @@ -34,13 +34,13 @@ define(["require", "exports", "tslib", "../Core"], function (require, exports, t failure(); } window[callbackName] = undefined; - script.parentNode.removeChild(script); + script.remove(); }, (~~options.timeout || 10) * 1000); window[callbackName] = (...args) => { window.clearTimeout(timeout); success.apply(null, args); window[callbackName] = undefined; - script.parentNode.removeChild(script); + script.remove(); }; url += (url.indexOf('?') === -1) ? '?' : '&'; url += options.parameterName + '=' + callbackName; diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js index 83f5235ce0..5c2cb0b496 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Request.js @@ -284,7 +284,7 @@ define(["require", "exports", "tslib", "./Status", "../Core", "../Dom/Change/Lis this._previousXhr = undefined; Listener_1.default.trigger(); // fix anchor tags generated through WCF::getAnchor() - document.querySelectorAll('a[href*="#"]').forEach(link => { + document.querySelectorAll('a[href*="#"]').forEach((link) => { let href = link.href; if (href.indexOf('AJAXProxy') !== -1 || href.indexOf('ajax-proxy') !== -1) { href = href.substr(href.indexOf('#')); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/CallbackList.js b/wcfsetup/install/files/js/WoltLabSuite/Core/CallbackList.js index 04d5ba7fcc..26cdf99eb7 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/CallbackList.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/CallbackList.js @@ -37,7 +37,7 @@ define(["require", "exports"], function (require, exports) { forEach(identifier, callback) { var _a; if (identifier === null) { - this._callbacks.forEach(function (callbacks, identifier) { + this._callbacks.forEach((callbacks, identifier) => { callbacks.forEach(callback); }); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Image/Resizer.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Image/Resizer.js index 6136663f9f..9b9443c841 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Image/Resizer.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Image/Resizer.js @@ -82,18 +82,18 @@ define(["require", "exports", "tslib", "../FileUtil", "./ExifUtil", "pica"], fun // Strip EXIF data fileData = await ExifUtil.removeExifData(fileData); } - const imageLoader = new Promise(function (resolve, reject) { + const imageLoader = new Promise((resolve, reject) => { const reader = new FileReader(); const image = new Image(); - reader.addEventListener("load", function () { + reader.addEventListener("load", () => { image.src = reader.result; }); - reader.addEventListener("error", function () { + reader.addEventListener("error", () => { reader.abort(); reject(reader.error); }); image.addEventListener("error", reject); - image.addEventListener("load", function () { + image.addEventListener("load", () => { resolve(image); }); reader.readAsDataURL(fileData); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Confirmation.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Confirmation.js index b800e9b232..09e2d61ddd 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Confirmation.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Confirmation.js @@ -31,7 +31,7 @@ define(["require", "exports", "tslib", "../Core", "../Language", "./Dialog"], fu this.confirmButton = document.createElement('button'); this.confirmButton.classList.add('buttonPrimary'); this.confirmButton.textContent = Language.get('wcf.global.confirmation.confirm'); - this.confirmButton.addEventListener('click', this._confirm.bind(this)); + this.confirmButton.addEventListener('click', (ev) => this._confirm()); formSubmit.appendChild(this.confirmButton); const cancelButton = document.createElement('button'); cancelButton.textContent = Language.get('wcf.global.confirmation.cancel'); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js index aec10acfe2..25a4225596 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js @@ -53,7 +53,7 @@ define(["require", "exports", "tslib", "../Core", "../Dom/Change/Listener", "./S _container = document.createElement('div'); _container.classList.add('dialogOverlay'); _container.setAttribute('aria-hidden', 'true'); - _container.addEventListener('mousedown', this._closeOnBackdrop.bind(this)); + _container.addEventListener('mousedown', (ev) => this._closeOnBackdrop(ev)); _container.addEventListener('wheel', event => { if (event.target === _container) { event.preventDefault(); @@ -82,7 +82,9 @@ define(["require", "exports", "tslib", "../Core", "../Dom/Change/Listener", "./S }, }); this._initStaticDialogs(); - Listener_1.default.add('Ui/Dialog', this._initStaticDialogs.bind(this)); + Listener_1.default.add('Ui/Dialog', () => { + this._initStaticDialogs(); + }); UiScreen.setDialogContainer(_container); window.addEventListener('resize', () => { _dialogs.forEach(dialog => { @@ -93,7 +95,7 @@ define(["require", "exports", "tslib", "../Core", "../Dom/Change/Listener", "./S }); }, _initStaticDialogs() { - document.querySelectorAll('.jsStaticDialog').forEach(button => { + document.querySelectorAll('.jsStaticDialog').forEach((button) => { button.classList.remove('jsStaticDialog'); const id = button.dataset.dialogId || ''; if (id) { @@ -306,7 +308,7 @@ define(["require", "exports", "tslib", "../Core", "../Dom/Change/Listener", "./S closeButton.tabIndex = 0; closeButton.title = options.closeButtonLabel; closeButton.setAttribute('aria-label', options.closeButtonLabel); - closeButton.addEventListener('click', this._close.bind(this)); + closeButton.addEventListener('click', (ev) => this._close(ev)); header.appendChild(closeButton); const span = document.createElement('span'); span.className = 'icon icon24 fa-times'; diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dropdown/Builder.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dropdown/Builder.js index dd1708d276..a12491e47b 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dropdown/Builder.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dropdown/Builder.js @@ -150,9 +150,6 @@ define(["require", "exports", "tslib", "../../Core", "./Simple"], function (requ * Attaches the list to a button, visibility is from then on controlled through clicks * on the provided button element. Internally calls `Ui/SimpleDropdown.initFragment()` * to delegate the DOM management. - * - * @param {Element} list - * @param {Element} button */ function attach(list, button) { validateList(list); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dropdown/Simple.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dropdown/Simple.js index 8ca05bf7ac..3833c56b35 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dropdown/Simple.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dropdown/Simple.js @@ -266,8 +266,9 @@ define(["require", "exports", "tslib", "../../CallbackList", "../../Core", "../. button = dropdown.querySelector('.dropdownToggle'); const mouseEvent = dropdown.dataset.a11yMouseEvent || 'click'; Core.triggerEvent(target, mouseEvent); - if (button) + if (button) { button.focus(); + } } else if (event.key === 'Escape' || event.key === 'Tab') { event.preventDefault(); diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/JumpTo.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/JumpTo.js index 473114031c..bfd4f4e236 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/JumpTo.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/JumpTo.js @@ -36,8 +36,8 @@ define(["require", "exports", "tslib", "../../Language", "../Dialog"], function throw new TypeError("Expected a valid function for parameter 'callback'."); } if (!this.elements.has(element)) { - element.querySelectorAll('.jumpTo').forEach(jumpTo => { - jumpTo.addEventListener('click', this.click.bind(this, element)); + element.querySelectorAll('.jumpTo').forEach((jumpTo) => { + jumpTo.addEventListener('click', (ev) => this.click(element, ev)); this.elements.set(element, callback); }); } @@ -92,10 +92,10 @@ define(["require", "exports", "tslib", "../../Language", "../Dialog"], function options: { onSetup: content => { this.input = content.querySelector('input'); - this.input.addEventListener('keyup', this._keyUp.bind(this)); + this.input.addEventListener('keyup', (ev) => this._keyUp(ev)); this.description = content.querySelector('small'); this.submitButton = content.querySelector('button'); - this.submitButton.addEventListener('click', this.submit.bind(this)); + this.submitButton.addEventListener('click', () => this.submit()); }, title: Language.get('wcf.global.page.pagination'), }, diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Search.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Search.js index 6ef6a9fe35..6879401c10 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Search.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Page/Search.js @@ -58,8 +58,8 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Dom/Util", "../../La this.resultList.innerHTML = html; Util_1.default[html ? 'show' : 'hide'](this.resultContainer); if (html) { - this.resultList.querySelectorAll('.containerHeadline').forEach(item => { - item.addEventListener('click', this.click.bind(this)); + this.resultList.querySelectorAll('.containerHeadline').forEach((item) => { + item.addEventListener('click', (ev) => this.click(ev)); }); } else { @@ -85,7 +85,7 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Dom/Util", "../../La this.search(event); } }); - this.searchInput.nextElementSibling.addEventListener('click', this.search.bind(this)); + this.searchInput.nextElementSibling.addEventListener('click', (ev) => this.search(ev)); this.resultContainer = document.getElementById('wcfUiPageSearchResultContainer'); this.resultList = document.getElementById('wcfUiPageSearchResultList'); }, diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Pagination.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Pagination.js index 157b31e9a8..f57020c3ad 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Pagination.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Pagination.js @@ -53,7 +53,7 @@ define(["require", "exports", "tslib", "../Core", "../Language", "../StringUtil" link.title = Language.get('wcf.global.page.previous'); link.rel = 'prev'; listItem.appendChild(link); - link.addEventListener('click', this.switchPage.bind(this, this.activePage - 1)); + link.addEventListener('click', (ev) => this.switchPage(this.activePage - 1, ev)); } else { listItem.innerHTML = ''; @@ -153,7 +153,7 @@ define(["require", "exports", "tslib", "../Core", "../Language", "../StringUtil" link.title = Language.get('wcf.global.page.next'); link.rel = 'next'; listItem.appendChild(link); - link.addEventListener('click', this.switchPage.bind(this, this.activePage + 1)); + link.addEventListener('click', (ev) => this.switchPage(this.activePage + 1, ev)); } else { listItem.innerHTML = ''; @@ -173,7 +173,7 @@ define(["require", "exports", "tslib", "../Core", "../Language", "../StringUtil" if (pageNo !== this.activePage) { const link = document.createElement('a'); link.textContent = StringUtil.addThousandsSeparator(pageNo); - link.addEventListener('click', this.switchPage.bind(this, pageNo)); + link.addEventListener('click', (ev) => this.switchPage(pageNo, ev)); listItem.appendChild(link); } else { diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Screen.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Screen.js index e2f4c984ac..09d912638a 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Screen.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Screen.js @@ -205,20 +205,20 @@ define(["require", "exports", "tslib", "../Core", "../Environment"], function (r const queryObject = _getQueryObject(event.media); if (event.matches) { if (queryObject.callbacksSetup.size) { - queryObject.callbacksSetup.forEach(function (callback) { + queryObject.callbacksSetup.forEach((callback) => { callback(); }); // discard all setup callbacks after execution queryObject.callbacksSetup = new Map(); } else { - queryObject.callbacksMatch.forEach(function (callback) { + queryObject.callbacksMatch.forEach((callback) => { callback(); }); } } else { - queryObject.callbacksUnmatch.forEach(function (callback) { + queryObject.callbacksUnmatch.forEach((callback) => { callback(); }); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Input.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Input.js index e0b4999bfa..10b814bef9 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Input.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Search/Input.js @@ -64,8 +64,8 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Core", "../../Dom/Ut this.preventSubmit = options.preventSubmit; // Disable auto-complete because it collides with the suggestion dropdown. this.element.autocomplete = 'off'; - this.element.addEventListener('keydown', this.keydown.bind(this)); - this.element.addEventListener('keyup', this.keyup.bind(this)); + this.element.addEventListener('keydown', (ev) => this.keydown(ev)); + this.element.addEventListener('keyup', (ev) => this.keyup(ev)); } /** * Adds an excluded search value. diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Smiley/Insert.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Smiley/Insert.js index cd258f523a..d546563042 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Smiley/Insert.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Smiley/Insert.js @@ -21,8 +21,8 @@ define(["require", "exports", "tslib", "../../Event/Handler"], function (require } } this.container = container; - this.container.addEventListener('keydown', this.keydown.bind(this)); - this.container.addEventListener('mousedown', this.mousedown.bind(this)); + this.container.addEventListener('keydown', (ev) => this.keydown(ev)); + this.container.addEventListener('mousedown', (ev) => this.mousedown(ev)); } keydown(event) { const activeButton = document.activeElement; @@ -64,8 +64,9 @@ define(["require", "exports", "tslib", "../../Event/Handler"], function (require if (listItem && this.container.contains(listItem)) { event.preventDefault(); const img = listItem.querySelector('img'); - if (img) + if (img) { this.insert(img); + } } } insert(img) { diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Suggestion.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Suggestion.js index 9a474ffc9e..a8858d03a3 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Suggestion.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Suggestion.js @@ -37,9 +37,9 @@ define(["require", "exports", "tslib", "../Ajax", "../Core", "./Dropdown/Simple" this.callbackSelect = options.callbackSelect; this.excludedSearchValues = new Set(Array.isArray(options.excludedSearchValues) ? options.excludedSearchValues : []); this.threshold = options.threshold === undefined ? 3 : options.threshold; - this.element.addEventListener('click', event => event.preventDefault()); - this.element.addEventListener('keydown', this.keyDown.bind(this)); - this.element.addEventListener('keyup', this.keyUp.bind(this)); + this.element.addEventListener('click', (ev) => ev.preventDefault()); + this.element.addEventListener('keydown', (ev) => this.keyDown(ev)); + this.element.addEventListener('keyup', (ev) => this.keyUp(ev)); } /** * Adds an excluded search value. @@ -109,9 +109,6 @@ define(["require", "exports", "tslib", "../Ajax", "../Core", "./Dropdown/Simple" event.preventDefault(); return false; } - /** - * Selects an item from the list. - */ select(event, item) { if (event instanceof MouseEvent) { const target = event.currentTarget; @@ -185,7 +182,7 @@ define(["require", "exports", "tslib", "../Ajax", "../Core", "./Dropdown/Simple" if (item.type) { anchor.dataset.type = item.type; } - anchor.addEventListener('click', this.select.bind(this)); + anchor.addEventListener('click', (ev) => this.select(ev)); const listItem = document.createElement('li'); if (index === 0) { listItem.className = 'active'; diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu.js index c18ac91a52..86d28bfa93 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu.js @@ -63,7 +63,7 @@ define(["require", "exports", "tslib", "../Dom/Change/Listener", "../Dom/Util", rebuildMenuOverflow(menu); } let timeout = null; - menu.querySelector('ul').addEventListener('scroll', function () { + menu.querySelector('ul').addEventListener('scroll', () => { if (timeout !== null) { window.clearTimeout(timeout); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu/Simple.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu/Simple.js index b58e6433f7..05ba0ca209 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu/Simple.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/TabMenu/Simple.js @@ -95,7 +95,8 @@ define(["require", "exports", "tslib", "../../Dom/Traverse", "../../Dom/Util", " // bind listeners this.tabs.forEach(tab => { if (!oldTabs || oldTabs.get(tab.dataset.name || '') !== tab) { - tab.children[0].addEventListener('click', this._onClick.bind(this)); + const firstChild = tab.children[0]; + firstChild.addEventListener('click', (ev) => this._onClick(ev)); // iOS 13 changed the behavior for click events after scrolling the menu. It prevents // the synthetic mouse events like "click" from triggering for a short duration after // a scrolling has occurred. If the user scrolls to the end of the list and immediately @@ -108,13 +109,13 @@ define(["require", "exports", "tslib", "../../Dom/Traverse", "../../Dom/Util", " // tapping a menu item. if (Environment.platform() === 'ios') { let isClick = false; - tab.children[0].addEventListener('touchstart', () => { + firstChild.addEventListener('touchstart', () => { isClick = true; }); - tab.children[0].addEventListener('touchmove', () => { + firstChild.addEventListener('touchmove', () => { isClick = false; }); - tab.children[0].addEventListener('touchend', (event) => { + firstChild.addEventListener('touchend', (event) => { if (isClick) { isClick = false; // This will block the regular click event from firing. diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Toggle/Input.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Toggle/Input.js index 0a05dda5ae..35edb88db6 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Toggle/Input.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Toggle/Input.js @@ -39,7 +39,7 @@ define(["require", "exports", "tslib", "../../Dom/Util"], function (require, exp this.element = element; this.hide = this.getElements('hide', Array.isArray(options.hide) ? options.hide : []); this.hide = this.getElements('show', Array.isArray(options.show) ? options.show : []); - this.element.addEventListener('change', this.change.bind(this)); + this.element.addEventListener('change', (ev) => this.change(ev)); this.updateVisibility(this.show, this.element.checked); this.updateVisibility(this.hide, !this.element.checked); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Tooltip.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Tooltip.js index 3f07f0fa29..4ab5e9568b 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Tooltip.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Tooltip.js @@ -90,7 +90,7 @@ define(["require", "exports", "tslib", "../Dom/Change/Listener", "../Environment * Initializes tooltip elements. */ function init() { - document.querySelectorAll('.jsTooltip').forEach(element => { + document.querySelectorAll('.jsTooltip').forEach((element) => { element.classList.remove('jsTooltip'); const title = element.title.trim(); if (title.length) { diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Editor.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Editor.js index e8da413585..4bb60a6aa0 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Editor.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Editor.js @@ -26,7 +26,7 @@ define(["require", "exports", "tslib", "../../Ajax", "../../Core", "../../Dom/Ut // The button is missing if the current user lacks the permission. if (button) { button.dataset.action = action; - button.addEventListener('click', this._click.bind(this)); + button.addEventListener('click', (ev) => this._click(ev)); } }); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Trophy/List.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Trophy/List.js index 9c6c9500ed..70d4eae019 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Trophy/List.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Trophy/List.js @@ -46,7 +46,7 @@ define(["require", "exports", "tslib", "../../../Ajax", "../../../Dom/Change/Lis rebuild() { document.querySelectorAll('.userTrophyOverlayList').forEach((element) => { if (!this.knownElements.has(element)) { - element.addEventListener('click', this.open.bind(this, element)); + element.addEventListener('click', (ev) => this.open(element, ev)); this.knownElements.add(element); } }); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Jsonp.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Jsonp.ts index dbd34f60cf..35bdce673f 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Jsonp.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Jsonp.ts @@ -37,7 +37,7 @@ export function send(url: string, success: (...args: unknown[]) => void, failure } window[callbackName] = undefined; - script.parentNode.removeChild(script); + script.remove(); }, (~~options.timeout || 10) * 1_000); window[callbackName] = (...args: any[]) => { @@ -46,7 +46,7 @@ export function send(url: string, success: (...args: unknown[]) => void, failure success.apply(null, args); window[callbackName] = undefined; - script.parentNode.removeChild(script); + script.remove(); }; url += (url.indexOf('?') === -1) ? '?' : '&'; diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Request.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Request.ts index 8f71a15257..536795e35a 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Request.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Request.ts @@ -330,7 +330,7 @@ class AjaxRequest { DomChangeListener.trigger(); // fix anchor tags generated through WCF::getAnchor() - document.querySelectorAll('a[href*="#"]').forEach(link => { + document.querySelectorAll('a[href*="#"]').forEach((link: HTMLAnchorElement) => { let href = link.href; if (href.indexOf('AJAXProxy') !== -1 || href.indexOf('ajax-proxy') !== -1) { href = href.substr(href.indexOf('#')); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/CallbackList.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/CallbackList.ts index d888ecd374..1ddefeff12 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/CallbackList.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/CallbackList.ts @@ -38,7 +38,7 @@ class CallbackList { */ forEach(identifier: string | null, callback: Callback): void { if (identifier === null) { - this._callbacks.forEach(function (callbacks, identifier) { + this._callbacks.forEach((callbacks, identifier) => { callbacks.forEach(callback); }); } else { diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Date/Time/Relative.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Date/Time/Relative.ts index 7797305058..85f5455275 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Date/Time/Relative.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Date/Time/Relative.ts @@ -42,7 +42,7 @@ function refresh() { } const date = new Date(); - const timestamp = (date.getTime() - date.getMilliseconds()) / 1000; + const timestamp = (date.getTime() - date.getMilliseconds()) / 1_000; if (_offset === null) _offset = timestamp - window.TIME_NOW; document.querySelectorAll('time').forEach(element => { @@ -100,7 +100,7 @@ function rebuild(element: HTMLTimeElement, date: Date, timestamp: number): void * Transforms