-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Patch ElementUI tooltip memory leak
- Loading branch information
Showing
3 changed files
with
82 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,9 @@ | |
"vue-demi": "^0.12.1", | ||
"vue": "~2.6.14", | ||
"vue-template-compiler": "~2.6.11" | ||
}, | ||
"patchedDependencies": { | ||
"[email protected]": "patches/[email protected]" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
diff --git a/lib/element-ui.common.js b/lib/element-ui.common.js | ||
index 01026cd93f233f08c0f77c1eeffc43b7953ea75e..3f5486798f53c03f57fdfc15b9d8547d97c7fa09 100644 | ||
--- a/lib/element-ui.common.js | ||
+++ b/lib/element-ui.common.js | ||
@@ -21781,18 +21781,7 @@ main.directive = directive; | ||
this.$el.setAttribute('tabindex', this.tabindex); | ||
Object(dom_["on"])(this.referenceElm, 'mouseenter', this.show); | ||
Object(dom_["on"])(this.referenceElm, 'mouseleave', this.hide); | ||
- Object(dom_["on"])(this.referenceElm, 'focus', function () { | ||
- if (!_this3.$slots.default || !_this3.$slots.default.length) { | ||
- _this3.handleFocus(); | ||
- return; | ||
- } | ||
- var instance = _this3.$slots.default[0].componentInstance; | ||
- if (instance && instance.focus) { | ||
- instance.focus(); | ||
- } else { | ||
- _this3.handleFocus(); | ||
- } | ||
- }); | ||
+ Object(dom_["on"])(this.referenceElm, 'focus', this.handleFocus); | ||
Object(dom_["on"])(this.referenceElm, 'blur', this.handleBlur); | ||
Object(dom_["on"])(this.referenceElm, 'click', this.removeFocusing); | ||
} | ||
diff --git a/packages/tooltip/src/main.js b/packages/tooltip/src/main.js | ||
index 6b700bba8f38691d738927e75423d9a902fe245e..57a3e640c05b19c205817e5d3608bb8623a51a1c 100644 | ||
--- a/packages/tooltip/src/main.js | ||
+++ b/packages/tooltip/src/main.js | ||
@@ -113,18 +113,7 @@ export default { | ||
this.$el.setAttribute('tabindex', this.tabindex); | ||
on(this.referenceElm, 'mouseenter', this.show); | ||
on(this.referenceElm, 'mouseleave', this.hide); | ||
- on(this.referenceElm, 'focus', () => { | ||
- if (!this.$slots.default || !this.$slots.default.length) { | ||
- this.handleFocus(); | ||
- return; | ||
- } | ||
- const instance = this.$slots.default[0].componentInstance; | ||
- if (instance && instance.focus) { | ||
- instance.focus(); | ||
- } else { | ||
- this.handleFocus(); | ||
- } | ||
- }); | ||
+ on(this.referenceElm, 'focus', this.handleFocus); | ||
on(this.referenceElm, 'blur', this.handleBlur); | ||
on(this.referenceElm, 'click', this.removeFocusing); | ||
} | ||
@@ -157,6 +146,18 @@ export default { | ||
this.debounceClose(); | ||
}, | ||
handleFocus() { | ||
+ if (!this.$slots.default || !this.$slots.default.length) { | ||
+ this.doFocus(); | ||
+ return; | ||
+ } | ||
+ const instance = this.$slots.default[0].componentInstance; | ||
+ if (instance && instance.focus) { | ||
+ instance.focus(); | ||
+ } else { | ||
+ this.doFocus(); | ||
+ } | ||
+ }, | ||
+ doFocus() { | ||
this.focusing = true; | ||
this.show(); | ||
}, |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.