Browse Source

fix: cleartimeout memory leak (#1785)

(cherry picked from commit cde47328d9c97c0c34a356f75421ed19a0e865df)
代强 2 years ago
parent
commit
126355650e

+ 3 - 2
packages/semi-foundation/navigation/subNavFoundation.ts

@@ -52,7 +52,9 @@ export default class SubNavFoundation<P = Record<string, any>, S = Record<string
         this._timer = null;
     }
 
-    destroy() {} // eslint-disable-line
+    destroy() {
+        this.clearDelayTimer();
+    }
 
     clearDelayTimer() {
         if (this._timer) {
@@ -62,7 +64,6 @@ export default class SubNavFoundation<P = Record<string, any>, S = Record<string
     }
 
     isValidKey(itemKey: string | number) {
-        // eslint-disable-next-line eqeqeq
         return itemKey != null && (typeof itemKey === 'number' || typeof itemKey === 'string');
     }
 

+ 1 - 0
packages/semi-foundation/tooltip/foundation.ts

@@ -115,6 +115,7 @@ export default class Tooltip<P = Record<string, any>, S = Record<string, any>> e
         this._adapter.unregisterClickOutsideHandler();
         this.unBindResizeEvent();
         this.unBindScrollEvent();
+        clearTimeout(this._timer);
     }
 
     _bindTriggerEvent(triggerEventSet: Record<string, any>) {