Procházet zdrojové kódy

Switch to loop instead of recursion

Saul Shanabrook před 5 roky
rodič
revize
bfe2739613
1 změnil soubory, kde provedl 6 přidání a 10 odebrání
  1. 6 10
      packages/application/src/frontend.ts

+ 6 - 10
packages/application/src/frontend.ts

@@ -356,16 +356,12 @@ namespace Private {
   /**
    * Returns whether the element is itself, or a child of, an element with the `jp-suppress-context-menu` data attribute.
    */
-  export function suppressContextMenu({
-    dataset,
-    parentElement
-  }: HTMLElement): boolean {
-    // Any value of data property means its active.
-    if (typeof dataset.jpSuppressContextMenu === 'string') {
-      return true;
-    }
-    if (parentElement) {
-      return suppressContextMenu(parentElement);
+  export function suppressContextMenu(element: HTMLElement | null): boolean {
+    while (element) {
+      if (typeof element.dataset.jpSuppressContextMenu === 'string') {
+        return true;
+      }
+      element = element.parentElement;
     }
     return false;
   }