Skip to content

fix(docs): clear event listeners before component unmounts #7193

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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 @@
}

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

beforeDestroy() {

Check warning on line 255 in docs/components/contributors.vue

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest, 20)

The "beforeDestroy" property should be above the "methods" property on line 110
this.controller.abort()
},

created() {

Check warning on line 259 in docs/components/contributors.vue

View workflow job for this annotation

GitHub Actions / lint (ubuntu-latest, 20)

The "created" property should be above the "methods" property on line 110
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
Loading