fix(nuxt): swallow issues with query selectors (#8843)

This commit is contained in:
Daniel Roe 2022-11-09 10:10:32 +01:00 committed by GitHub
parent 14307d1327
commit 453ce78300
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 4 deletions

View File

@ -48,10 +48,12 @@ export default <RouterConfig> {
}
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
}