Skip to content

Commit

Permalink
fix(compiler): force reset toc when rendering sidebar fixed #181
Browse files Browse the repository at this point in the history
  • Loading branch information
QingWei-Li committed Jun 2, 2017
1 parent 9b15d8d commit ccf4c7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/core/render/compiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ export class Compiler {
* Compile sub sidebar
*/
subSidebar (level) {
if (!level) {
this.toc = []
return
}
const currentPath = this.router.getCurrentPath()
const { cacheTree, toc } = this

Expand Down
3 changes: 3 additions & 0 deletions src/core/render/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export function renderMixin (proto) {
const activeEl = getAndActive(this.router, '.sidebar-nav', true, true)
if (loadSidebar && activeEl) {
activeEl.parentNode.innerHTML += this.compiler.subSidebar(subMaxLevel)
} else {
// reset toc
this.compiler.subSidebar()
}
// bind event
this._bindEventOnRendered()
Expand Down

0 comments on commit ccf4c7c

Please sign in to comment.