Re-create elements in `Upload._createButton()`
authorMatthias Schmidt <gravatronics@live.com>
Sat, 2 Jan 2021 13:11:00 +0000 (14:11 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 2 Jan 2021 13:11:00 +0000 (14:11 +0100)
The logic relies on these elements being recreated as it was done before the conversion to TypeScript.

See 2c22735da3519b9786ae141d072cbf9adee2a72c

wcfsetup/install/files/js/WoltLabSuite/Core/Upload.js
wcfsetup/install/files/ts/WoltLabSuite/Core/Upload.ts

index e4d9e134d976799dc2a7b53e1837a351760a5787..5fb7bdcb3568fddd904484a7c25345cbc023926c 100644 (file)
@@ -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", () => {
index a0ae2c7f68d30c6f8f3d93d7a893e21329e7b14c..801f0a9374d3928c5d7f1482b4c871b520fb6e6a 100644 (file)
@@ -16,10 +16,10 @@ import * as Language from "./Language";
 import { FileCollection, FileElements, FileLikeObject, UploadId, UploadOptions } from "./Upload/Data";
 
 abstract class Upload<TOptions extends UploadOptions = UploadOptions> {
-  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<TOptions extends UploadOptions = UploadOptions> {
    * 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<TOptions extends UploadOptions = UploadOptions> {
     }
     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", () => {