feat(external-script): detect more than one script dom, fixed #146

This commit is contained in:
qingwei.li 2017-04-12 23:51:16 +08:00
commit 94d6603c06

View file

@ -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)