Skip to content

Commit

Permalink
fix($active-header-links): unexpected error when anchors were empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ulivz committed Nov 5, 2018
1 parent 91a5bd4 commit d658169
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/@vuepress/plugin-active-header-links/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@ export default {

methods: {
onScroll: throttle(function () {
const anchors = getAnchors()
if (anchors.length === 0) {
return
}
this.$lastAnchor = this.$currentAnchor
this.$currentAnchor = calculateCurrentAnchor(getAnchors())
this.$currentAnchor = calculateCurrentAnchor(anchors)
if (!this.$lastAnchor || this.$lastAnchor.hash !== this.$currentAnchor.hash) {
this.$vuepress.$emit('AnchorHashChange', this.$currentAnchor)
}
Expand Down

0 comments on commit d658169

Please sign in to comment.