From: Matthias Schmidt Date: Sat, 2 Jan 2021 13:11:00 +0000 (+0100) Subject: Re-create elements in `Upload._createButton()` X-Git-Tag: 5.4.0_Alpha_1~496 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=a995bad47631e0fe6a64015bf93ba756e048740c;p=GitHub%2FWoltLab%2FWCF.git Re-create elements in `Upload._createButton()` The logic relies on these elements being recreated as it was done before the conversion to TypeScript. See 2c22735da3519b9786ae141d072cbf9adee2a72c --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Upload.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Upload.js index e4d9e134d9..5fb7bdcb35 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Upload.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Upload.js @@ -65,6 +65,7 @@ define(["require", "exports", "tslib", "./Ajax/Request", "./Core", "./Dom/Change * Creates the upload button. */ _createButton() { + this._fileUpload = document.createElement("input"); this._fileUpload.type = "file"; this._fileUpload.name = this._options.name; if (this._options.multiple) { @@ -74,6 +75,7 @@ define(["require", "exports", "tslib", "./Ajax/Request", "./Core", "./Dom/Change this._fileUpload.accept = this._options.acceptableFiles.join(","); } this._fileUpload.addEventListener("change", (ev) => this._upload(ev)); + this._button = document.createElement("p"); this._button.className = "button uploadButton"; this._button.setAttribute("role", "button"); this._fileUpload.addEventListener("focus", () => { diff --git a/wcfsetup/install/files/ts/WoltLabSuite/Core/Upload.ts b/wcfsetup/install/files/ts/WoltLabSuite/Core/Upload.ts index a0ae2c7f68..801f0a9374 100644 --- a/wcfsetup/install/files/ts/WoltLabSuite/Core/Upload.ts +++ b/wcfsetup/install/files/ts/WoltLabSuite/Core/Upload.ts @@ -16,10 +16,10 @@ import * as Language from "./Language"; import { FileCollection, FileElements, FileLikeObject, UploadId, UploadOptions } from "./Upload/Data"; abstract class Upload { - protected readonly _button = document.createElement("p"); + protected _button = document.createElement("p"); protected readonly _buttonContainer: HTMLElement; protected readonly _fileElements: FileElements[] = []; - protected readonly _fileUpload = document.createElement("input"); + protected _fileUpload = document.createElement("input"); protected _internalFileId = 0; protected readonly _multiFileUploadIds: unknown[] = []; protected readonly _options: TOptions; @@ -83,6 +83,7 @@ abstract class Upload { * Creates the upload button. */ protected _createButton(): void { + this._fileUpload = document.createElement("input"); this._fileUpload.type = "file"; this._fileUpload.name = this._options.name; if (this._options.multiple) { @@ -93,6 +94,7 @@ abstract class Upload { } this._fileUpload.addEventListener("change", (ev) => this._upload(ev)); + this._button = document.createElement("p"); this._button.className = "button uploadButton"; this._button.setAttribute("role", "button"); this._fileUpload.addEventListener("focus", () => {