From 87f562d244dfca44b6c7e033309c2c238982a4bf Mon Sep 17 00:00:00 2001 From: Henrik Askjer <henrik.askjer@uib.no> Date: Tue, 28 Dec 2021 14:18:49 +0100 Subject: [PATCH] prevent undefined error --- src/components/Definition.vue | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/components/Definition.vue b/src/components/Definition.vue index 4645f999..84986743 100644 --- a/src/components/Definition.vue +++ b/src/components/Definition.vue @@ -82,10 +82,12 @@ var Definition = { watch:{ $route(to, from) { let ref = 'def' + this.body.id - if(location.hash.substring(1) == ref){ - this.$refs[ref].classList.add('highlighted') - }else{ - this.$refs[ref].classList.remove('highlighted') + if (this.$refs[ref]) { + if(location.hash.substring(1) == ref){ + this.$refs[ref].classList.add('highlighted') + }else { + this.$refs[ref].classList.remove('highlighted') + } } } } -- GitLab