Skip to content

Commit d658169

Browse files
committed
fix($active-header-links): unexpected error when anchors were empty
1 parent 91a5bd4 commit d658169

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

packages/@vuepress/plugin-active-header-links/mixin.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@ export default {
6868

6969
methods: {
7070
onScroll: throttle(function () {
71+
const anchors = getAnchors()
72+
if (anchors.length === 0) {
73+
return
74+
}
7175
this.$lastAnchor = this.$currentAnchor
72-
this.$currentAnchor = calculateCurrentAnchor(getAnchors())
76+
this.$currentAnchor = calculateCurrentAnchor(anchors)
7377
if (!this.$lastAnchor || this.$lastAnchor.hash !== this.$currentAnchor.hash) {
7478
this.$vuepress.$emit('AnchorHashChange', this.$currentAnchor)
7579
}

0 commit comments

Comments
 (0)