From 453ce78300c5937a0971d7a2d1309197d87bf3c6 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Wed, 9 Nov 2022 10:10:32 +0100 Subject: [PATCH] fix(nuxt): swallow issues with query selectors (#8843) --- packages/nuxt/src/pages/runtime/router.options.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/nuxt/src/pages/runtime/router.options.ts b/packages/nuxt/src/pages/runtime/router.options.ts index d5e8acc7e2..e358d54d1f 100644 --- a/packages/nuxt/src/pages/runtime/router.options.ts +++ b/packages/nuxt/src/pages/runtime/router.options.ts @@ -48,10 +48,12 @@ export default { } function _getHashElementScrollMarginTop (selector: string): number { - const elem = document.querySelector(selector) - if (elem) { - return parseFloat(getComputedStyle(elem).scrollMarginTop) - } + try { + const elem = document.querySelector(selector) + if (elem) { + return parseFloat(getComputedStyle(elem).scrollMarginTop) + } + } catch {} return 0 }