fix(nuxt): do not accept attrs on <NuxtErrorBoundary> (#28901)

This commit is contained in:
Daniel Roe 2024-09-09 21:37:55 +02:00
parent f94a2bf850
commit 667fe86956
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -2,6 +2,8 @@ import { defineComponent, onErrorCaptured, ref } from 'vue'
import { useNuxtApp } from '../nuxt'
export default defineComponent({
name: 'NuxtErrorBoundary',
inheritAttrs: false,
emits: {
error (_error: unknown) {
return true
@ -11,14 +13,16 @@ export default defineComponent({
const error = ref<Error | null>(null)
const nuxtApp = useNuxtApp()
onErrorCaptured((err, target, info) => {
if (import.meta.client && (!nuxtApp.isHydrating || !nuxtApp.payload.serverRendered)) {
emit('error', err)
nuxtApp.hooks.callHook('vue:error', err, target, info)
error.value = err
return false
}
})
if (import.meta.client) {
onErrorCaptured((err, target, info) => {
if (!nuxtApp.isHydrating || !nuxtApp.payload.serverRendered) {
emit('error', err)
nuxtApp.hooks.callHook('vue:error', err, target, info)
error.value = err
return false
}
})
}
function clearError () {
error.value = null