Skip to content

Commit

Permalink
fix(nuxt3): prevent removing and re-adding tags before mount (nuxt#3212)
Browse files Browse the repository at this point in the history
Co-authored-by: pooya parsa <pyapar@gmail.com>
  • Loading branch information
danielroe and pi0 authored Feb 15, 2022
1 parent 6a93719 commit ef69e74
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 6 additions & 0 deletions packages/bridge/src/runtime/app.plugin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,11 @@ export default (ctx, inject) => {

setNuxtAppInstance(proxiedApp)

if (process.client) {
window.onNuxtReady(() => {
nuxtApp.hooks.callHook('app:mounted', nuxtApp.vueApp)
})
}

inject('_nuxtApp', proxiedApp)
}
6 changes: 1 addition & 5 deletions packages/nuxt3/src/meta/runtime/lib/vueuse-head.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@ export default defineNuxtPlugin((nuxtApp) => {
const head = createHead()

nuxtApp.vueApp.use(head)
nuxtApp.hooks.hookOnce('app:mounted', () => { watchEffect(() => head.updateDOM()) })

nuxtApp._useMeta = (meta: MetaObject) => {
const headObj = ref(meta as any)
head.addHeadObjs(headObj)

if (process.server) { return }

watchEffect(() => {
head.updateDOM()
})

const vm = getCurrentInstance()
if (!vm) { return }

onBeforeUnmount(() => {
head.removeHeadObjs(headObj)
head.updateDOM()
})
}

Expand Down

0 comments on commit ef69e74

Please sign in to comment.