Make sure all consumers of the tooltip mixin clean up when unmounted.
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@tp/tp-tooltip",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"description": "",
|
||||
"main": "tp-tooltip.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -8,6 +8,8 @@ import './tp-tooltip.js';
|
||||
|
||||
/**
|
||||
* Elements implementing this mixin are able to show tooltip on mouse over.
|
||||
* The tooltip is automatically hidden and removed when the element is
|
||||
* disconnected from the DOM.
|
||||
*
|
||||
* ## Example
|
||||
* ```html
|
||||
@@ -52,6 +54,11 @@ export const Tooltip = function(superClass) {
|
||||
return this._tooltip;
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this._hideTooltip();
|
||||
}
|
||||
|
||||
_tooltipChanged(newTooltip, oldTooltip) {
|
||||
if (oldTooltip) {
|
||||
this.removeEventListener('mouseenter', this._showTooltip);
|
||||
|
||||
@@ -61,11 +61,6 @@ class TpTooltipWrapper extends Tooltip(LitElement) {
|
||||
return true;
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
super.disconnectedCallback();
|
||||
this._hideTooltip();
|
||||
}
|
||||
|
||||
_setTooltipText(text, disabled) {
|
||||
this.tooltip = disabled ? '' : text;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user