mirror of
https://gitee.com/ElemeFE/element.git
synced 2024-12-02 04:08:10 +08:00
* popover memory leak fix * actual fix
This commit is contained in:
parent
1f53559c20
commit
36bed61f97
@ -60,15 +60,7 @@ export default {
|
||||
}
|
||||
if (this.trigger === 'click') {
|
||||
on(reference, 'click', () => { this.showPopper = !this.showPopper; });
|
||||
on(document, 'click', (e) => {
|
||||
if (!this.$el ||
|
||||
!reference ||
|
||||
this.$el.contains(e.target) ||
|
||||
reference.contains(e.target) ||
|
||||
!popper ||
|
||||
popper.contains(e.target)) return;
|
||||
this.showPopper = false;
|
||||
});
|
||||
on(document, 'click', this.handleDocumentClick);
|
||||
} else if (this.trigger === 'hover') {
|
||||
on(reference, 'mouseenter', this.handleMouseEnter);
|
||||
on(popper, 'mouseenter', this.handleMouseEnter);
|
||||
@ -111,6 +103,21 @@ export default {
|
||||
this._timer = setTimeout(() => {
|
||||
this.showPopper = false;
|
||||
}, 200);
|
||||
},
|
||||
handleDocumentClick(e) {
|
||||
let reference = this.reference || this.$refs.reference;
|
||||
const popper = this.popper || this.$refs.popper;
|
||||
|
||||
if (!reference && this.$slots.reference && this.$slots.reference[0]) {
|
||||
reference = this.referenceElm = this.$slots.reference[0].elm;
|
||||
}
|
||||
if (!this.$el ||
|
||||
!reference ||
|
||||
this.$el.contains(e.target) ||
|
||||
reference.contains(e.target) ||
|
||||
!popper ||
|
||||
popper.contains(e.target)) return;
|
||||
this.showPopper = false;
|
||||
}
|
||||
},
|
||||
|
||||
@ -123,6 +130,7 @@ export default {
|
||||
off(reference, 'blur');
|
||||
off(reference, 'mouseleave');
|
||||
off(reference, 'mouseenter');
|
||||
off(document, 'click', this.handleDocumentClick);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user