mirror of https://github.com/Lissy93/dashy.git
🔒 Properly deregisters event listener on destroy
This commit is contained in:
parent
76ea9e0cee
commit
051ed1841c
|
@ -35,13 +35,8 @@ export default {
|
||||||
this.initiate();
|
this.initiate();
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
if (this.eventListener) {
|
window.removeEventListener('load', this.injectHtml);
|
||||||
window.removeEventListener(this.eventListener);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
data: () => ({
|
|
||||||
eventListener: null,
|
|
||||||
}),
|
|
||||||
methods: {
|
methods: {
|
||||||
/* Injects users content */
|
/* Injects users content */
|
||||||
injectHtml() {
|
injectHtml() {
|
||||||
|
@ -70,9 +65,7 @@ export default {
|
||||||
if (document.readyState === 'complete' || document.readyState === 'loaded') {
|
if (document.readyState === 'complete' || document.readyState === 'loaded') {
|
||||||
this.injectHtml();
|
this.injectHtml();
|
||||||
} else {
|
} else {
|
||||||
this.eventListener = window.addEventListener('load', () => {
|
window.addEventListener('load', this.injectHtml);
|
||||||
this.injectHtml();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
update() {
|
update() {
|
||||||
|
|
Loading…
Reference in New Issue