Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clear event listeners before component unmounts #7193

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/components/contributors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ export default {
}

xhr.open('GET', url, true)
xhr.addEventListener('load', onLoad)
xhr.addEventListener('load', onLoad, {
signal: this.controller?.signal
})
// Initiate the request
xhr.send()
},
Expand Down Expand Up @@ -248,6 +250,14 @@ export default {
// Donors are people/organizations with one-time (paid) donations
this.makeOcRequest(this.processDonors.bind(this), { status: 'paid' })
}
},

beforeDestroy() {
this.controller.abort()
},

created() {
this.controller = new window.AbortController()
}
}
</script>
Expand Down
8 changes: 7 additions & 1 deletion docs/components/quick-links.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@ export default {
}
},
created() {
this.$root.$on('docs-set-toc', toc => {
const handleDocsSetToc = toc => {
this.expanded = false
// Update the TOC content
this.toc = toc
}

this.$root.$on('docs-set-toc', handleDocsSetToc)

this.$once('hook:beforeDestroy', () => {
this.$root.$off('docs-set-toc', handleDocsSetToc)
})
},
mounted() {
Expand Down
8 changes: 7 additions & 1 deletion docs/components/toc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,14 @@ export default {
}
},
created() {
this.$root.$on('docs-set-toc', toc => {
const handleDocsSetToc = toc => {
this.toc = toc
}

this.$root.$on('docs-set-toc', handleDocsSetToc)

this.$once('hook:beforeDestroy', () => {
this.$root.$off('docs-set-toc', handleDocsSetToc)
})
},
mounted() {
Expand Down