Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detect more than one script doms. #146

Closed
fxioi opened this issue Apr 10, 2017 · 2 comments
Closed

detect more than one script doms. #146

fxioi opened this issue Apr 10, 2017 · 2 comments

Comments

@fxioi
Copy link

fxioi commented Apr 10, 2017

hi, in plugins/external-script.js, only can detect one script dom.
such as the (demo) (markdown raw)

function handleExternalScript () {
  var container = Docsify.dom.getNode('#main');
  var scripts = Docsify.dom.findAll(container, 'script');

  for (var i = scripts.length; i--;) {
    var script = scripts[i];
    
    if (script && script.src) {
      var newScript = document.createElement('script');
      ['src', 'async', 'defer'].forEach(function (attribute) {
        newScript[attribute] = script[attribute];
      });

      script.parentNode.insertBefore(newScript, script);
      script.parentNode.removeChild(script);
    }
  }
}
@QingWei-Li
Copy link
Member

PR welcome 😊

@fxioi
Copy link
Author

fxioi commented Apr 13, 2017

thx 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants