fix(bridge): don't call nuxt app if instance is inaccessible (#3906)

* fix(bridge): don't call nuxt app if instance is inaccessible

* fix: early return if no instance, for clarity
This commit is contained in:
Daniel Roe 2022-03-25 15:48:37 +00:00 committed by GitHub
parent 19842ce471
commit 9ebea904f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,10 +13,12 @@ declare module 'vue' {
const metaMixin = {
[metaConfig.mixinKey] () {
const instance = getCurrentInstance()
const options = instance?.type || /* nuxt2 */ instance?.proxy?.$options
const nuxtApp = useNuxtApp()
if (!instance) { return }
const options = instance.type || /* nuxt2 */ instance.proxy?.$options
if (!options || !('head' in options)) { return }
const nuxtApp = useNuxtApp()
const source = typeof options.head === 'function'
? computed(() => options.head(nuxtApp))
: options.head