From eaeab02a178511d623cbd66f413d21f724120f5c Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim=20D=C3=BCsterhus?= Date: Fri, 30 Oct 2020 11:15:19 +0100 Subject: [PATCH] Make Ajax/Jsonp.ts eslint clean --- wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Jsonp.js | 5 ++--- wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Jsonp.ts | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Jsonp.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Jsonp.js index e65438c050..ee4ea81d3d 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Jsonp.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ajax/Jsonp.js @@ -28,7 +28,7 @@ define(["require", "exports", "tslib", "../Core"], function (require, exports, t timeout: 10, }, options || {}); const callbackName = "wcf_jsonp_" + Core.getUuid().replace(/-/g, "").substr(0, 8); - let script; + const script = document.createElement("script"); const timeout = window.setTimeout(() => { if (typeof failure === "function") { failure(); @@ -38,13 +38,12 @@ define(["require", "exports", "tslib", "../Core"], function (require, exports, t }, (~~options.timeout || 10) * 1000); window[callbackName] = (...args) => { window.clearTimeout(timeout); - success.apply(null, args); + success(...args); window[callbackName] = undefined; script.remove(); }; url += url.indexOf("?") === -1 ? "?" : "&"; url += options.parameterName + "=" + callbackName; - script = document.createElement("script"); script.async = true; script.src = url; document.head.appendChild(script); diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Jsonp.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Ajax/Jsonp.ts index 6d5dc83b76..7638edbae1 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( ) as JsonpOptions; const callbackName = "wcf_jsonp_" + Core.getUuid().replace(/-/g, "").substr(0, 8); - let script; + const script = document.createElement("script"); const timeout = window.setTimeout(() => { if (typeof failure === "function") { @@ -51,7 +51,7 @@ export function send( window[callbackName] = (...args: any[]) => { window.clearTimeout(timeout); - success.apply(null, args); + success(...args); window[callbackName] = undefined; script.remove(); @@ -60,7 +60,6 @@ export function send( url += url.indexOf("?") === -1 ? "?" : "&"; url += options.parameterName + "=" + callbackName; - script = document.createElement("script"); script.async = true; script.src = url; -- 2.20.1