Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9155d00

Browse files
fix(docs): clear event listeners before component unmounts (#7193)
* Clear event listeners before component unmounts* fix: don't use optional chaining---------Co-authored-by: Jacob Müller <jacob.mueller.elz@gmail.com>
1 parent5bb20ce commit9155d00

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

‎docs/components/contributors.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,9 @@ export default {
135135
}
136136
137137
xhr.open('GET', url,true)
138-
xhr.addEventListener('load', onLoad)
138+
xhr.addEventListener('load', onLoad, {
139+
signal:this.controller?this.controller.signal:undefined
140+
})
139141
// Initiate the request
140142
xhr.send()
141143
},
@@ -248,6 +250,14 @@ export default {
248250
// Donors are people/organizations with one-time (paid) donations
249251
this.makeOcRequest(this.processDonors.bind(this), { status:'paid' })
250252
}
253+
},
254+
255+
beforeDestroy() {
256+
this.controller.abort()
257+
},
258+
259+
created() {
260+
this.controller=newwindow.AbortController()
251261
}
252262
}
253263
</script>

‎docs/components/quick-links.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,16 @@ export default {
5252
}
5353
},
5454
created() {
55-
this.$root.$on('docs-set-toc',toc=> {
55+
consthandleDocsSetToc=toc=> {
5656
this.expanded=false
5757
// Update the TOC content
5858
this.toc= toc
59+
}
60+
61+
this.$root.$on('docs-set-toc', handleDocsSetToc)
62+
63+
this.$once('hook:beforeDestroy', ()=> {
64+
this.$root.$off('docs-set-toc', handleDocsSetToc)
5965
})
6066
},
6167
mounted() {

‎docs/components/toc.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,14 @@ export default {
5757
}
5858
},
5959
created() {
60-
this.$root.$on('docs-set-toc',toc=> {
60+
consthandleDocsSetToc=toc=> {
6161
this.toc= toc
62+
}
63+
64+
this.$root.$on('docs-set-toc', handleDocsSetToc)
65+
66+
this.$once('hook:beforeDestroy', ()=> {
67+
this.$root.$off('docs-set-toc', handleDocsSetToc)
6268
})
6369
},
6470
mounted() {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp