Skip to content

Commit

Permalink
fix: 修复 issuse #35,scrollElement 参数设置为 DOM 节点报错问题;
Browse files Browse the repository at this point in the history
  • Loading branch information
yaohaixiao committed Oct 13, 2023
1 parent 1089588 commit 5836750
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion api/pug/script.pug
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ script.
defaults.showCode = false
defaults.position = 'sticky'
defaults.parentElement = '#aside'
defaults.scrollElement = '#main'
defaults.scrollElement = document.querySelector('#main')
defaults.articleElement = '#article'
defaults.git = 'https://github.com/yaohaixiao/outline.js'
defaults.tags = 'https://github.com/yaohaixiao/outline.js/tags'
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@
defaults.showCode = false
defaults.position = 'sticky'
defaults.parentElement = '#aside'
defaults.scrollElement = '#main'
defaults.scrollElement = document.querySelector('#main')
defaults.articleElement = '#article'
defaults.git = 'https://github.com/yaohaixiao/outline.js'
defaults.tags = 'https://github.com/yaohaixiao/outline.js/tags'
Expand Down
2 changes: 1 addition & 1 deletion docs/js/outline.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/js/outline.min.js.map

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion outline.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ class Outline extends Base {
render() {
const hasToolbar = this.attr('hasToolbar')
const scrollElement = this.attr('scrollElement')
const $scrollElement = document.querySelector(scrollElement)
let $scrollElement

if (isString(scrollElement)) {
$scrollElement = document.querySelector(scrollElement)
} else if (isElement(scrollElement)) {
$scrollElement = scrollElement
}

this._renderPrint()._renderAnchors()._renderChapters()._renderToolbar()

Expand Down
2 changes: 1 addition & 1 deletion outline.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion outline.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@yaohaixiao/outline.js",
"version": "3.30.0",
"version": "3.30.1",
"description": "outline.js - 自动生成文章导读(Table of Contents)导航的 JavaScript 工具。",
"main": "outline.min.js",
"files": [
Expand Down

0 comments on commit 5836750

Please sign in to comment.