feat(external-script): detect more than one script dom, fixed #146
This commit is contained in:
parent
920f624b5c
commit
94d6603c06
1 changed files with 12 additions and 8 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
function handleExternalScript () {
|
function handleExternalScript () {
|
||||||
const container = Docsify.dom.getNode('#main')
|
const container = Docsify.dom.getNode('#main')
|
||||||
const script = Docsify.dom.find(container, 'script')
|
const scripts = Docsify.dom.findAll(container, 'script')
|
||||||
|
|
||||||
|
for (let i = scripts.length; i--;) {
|
||||||
|
const script = scripts[i]
|
||||||
|
|
||||||
if (script && script.src) {
|
if (script && script.src) {
|
||||||
const newScript = document.createElement('script')
|
const newScript = document.createElement('script')
|
||||||
|
|
@ -13,6 +16,7 @@ function handleExternalScript () {
|
||||||
script.parentNode.removeChild(script)
|
script.parentNode.removeChild(script)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const install = function (hook) {
|
const install = function (hook) {
|
||||||
hook.doneEach(handleExternalScript)
|
hook.doneEach(handleExternalScript)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue