Skip to content

Commit 50c3cae

Browse files
committed
Fix: Add setTimeout in afterEach to ensure the correct document.title
1 parent 92eb068 commit 50c3cae

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

Diff for: src/index.js

+11-13
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,8 @@ export default function install (Vue, options = {}, router = null) {
2020
set (message, politeness) {
2121
if (!this.data) return
2222
this.reset()
23-
if (politeness) {
24-
this.data.politeness = politeness
25-
}
26-
draf(() => {
27-
this.data.content = message
28-
})
23+
this.data.politeness = politeness || this.data.politeness
24+
this.data.content = message
2925
},
3026

3127
polite (message) {
@@ -59,13 +55,15 @@ export default function install (Vue, options = {}, router = null) {
5955
if (announcer.skip) return
6056

6157
// draf: Resolves the problem of getting the correct document.title when the meta announcer is not passed
62-
// Tested on Vuepress
63-
draf(() => {
64-
const msg = announcer.message || document.title.trim()
65-
const complement = announcer.complementRoute || options.complementRoute
66-
const politeness = announcer.politeness || null
67-
Vue.prototype.$announcer.set(`${msg} ${complement}`, politeness)
68-
})
58+
// Tested on Vuepress and Nuxt
59+
setTimeout(() => {
60+
draf(() => {
61+
const msg = announcer.message || document.title.trim()
62+
const complement = announcer.complementRoute || options.complementRoute
63+
const politeness = announcer.politeness || null
64+
Vue.prototype.$announcer.set(`${msg} ${complement}`, politeness)
65+
})
66+
}, 500)
6967
})
7068
}
7169
}

0 commit comments

Comments
 (0)