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

View File

@ -48,10 +48,12 @@ export default <RouterConfig> {
} }
function _getHashElementScrollMarginTop (selector: string): number { function _getHashElementScrollMarginTop (selector: string): number {
const elem = document.querySelector(selector) try {
if (elem) { const elem = document.querySelector(selector)
return parseFloat(getComputedStyle(elem).scrollMarginTop) if (elem) {
} return parseFloat(getComputedStyle(elem).scrollMarginTop)
}
} catch {}
return 0 return 0
} }