Use the native click event if available
authorAlexander Ebert <ebert@woltlab.com>
Thu, 5 Nov 2020 22:22:43 +0000 (23:22 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 5 Nov 2020 22:22:43 +0000 (23:22 +0100)
wcfsetup/install/files/js/WoltLabSuite/Core/Core.js
wcfsetup/install/files/ts/WoltLabSuite/Core/Core.ts

index 26bec333ccac3473baa345779ee9852f6b8dd364..27d5f4ef5dcff83ad6f6af5eb7af6043a5a76a6c 100644 (file)
@@ -182,6 +182,10 @@ define(["require", "exports"], function (require, exports) {
      * Triggers a custom or built-in event.
      */
     function triggerEvent(element, eventName) {
+        if (eventName === "click" && element instanceof HTMLElement) {
+            element.click();
+            return;
+        }
         const event = new Event(eventName, {
             bubbles: true,
             cancelable: true,
index 534c01334ac1650a43bf6f899b86c9ce305aa50c..2f74a7adeb46d099192025b5e78d2b1dc816beff 100644 (file)
@@ -197,6 +197,11 @@ export function serialize(obj: object, prefix?: string): string {
  * Triggers a custom or built-in event.
  */
 export function triggerEvent(element: EventTarget, eventName: string): void {
+  if (eventName === "click" && element instanceof HTMLElement) {
+    element.click();
+    return;
+  }
+
   const event = new Event(eventName, {
     bubbles: true,
     cancelable: true,