Skip to content

[BUG] executes scripts twice #906

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

Closed
1 task done
trusktr opened this issue Aug 17, 2019 · 4 comments
Closed
1 task done

[BUG] executes scripts twice #906

trusktr opened this issue Aug 17, 2019 · 4 comments
Assignees
Labels
bug confirmed as a bug

Comments

@trusktr
Copy link
Member

trusktr commented Aug 17, 2019

Bug Report

If executeScript is true, then Docsify executes the content of the <script> twice. This causes bugs. Users don't expect a script tag to run twice.

Steps to reproduce

Just look here:

https://github.com/docsifyjs/docsify/blob/develop/src/core/render/index.js#L51-L64

That conditional statement will execute the content of the script by calling executeScript, and the browser will also naturally execute the script when the <script> is inserted into the DOM.

What is current behaviour

It executes the script twice!

What is the expected behaviour

Scripts should be executed only once.

Other relevant information

  • Bug does still occur when all/other plugins are disabled?

  • Docsify version: 4.9.4

@trusktr trusktr changed the title executes scripts twice [bug] executes scripts twice Aug 18, 2019
@anikethsaha
Copy link
Member

What is current behavior

It executes the script twice!

Did you face the execution of the script twice ? or its because of the code ? i

I think this might help, (though not 100% sure )

executeScript to true mean that running script tag coming from markdown. this are not the one which you are writing in the HTML's header tag or which you are writing to HTML page by yourself.
So as they are coming from markdown as a string and markdown are not parsing it, its skipping the rendering phase. So we need to manually run those code. So you can see here it's running the inner js code. Its like if you want to execute some javascript code in the HTML , then you can write it in the markdown and then it will be executed. Its not executing script tags outside of the markdown.

You can see the example here

Markdown-script-code

Preview-of how it executed

image

I hope this helps.
Closing this. Please comment if its unclear or anything is wrong with it 👍

@trusktr
Copy link
Member Author

trusktr commented Jan 23, 2022

Sorry for the late reply, but I saw Docsify running the script from the markdown (not the HTML template) twice. I need to investigate this, and will re-open this as a reminder.

@trusktr trusktr reopened this Jan 23, 2022
@trusktr trusktr self-assigned this Jan 23, 2022
@trusktr trusktr added the bug confirmed as a bug label Jan 23, 2022
@trusktr
Copy link
Member Author

trusktr commented Jan 23, 2022

#1732 might possibly lead to clues: doneEach unexpectedly runs twice.

@trusktr trusktr changed the title [bug] executes scripts twice [BUG] executes scripts twice Jan 23, 2022
@jhildenbiddle
Copy link
Member

Not seeing this behavior on 4.12.1. or 4.12.2. Closing for now, but feel free to reopen if the issue is reproducible.

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

No branches or pull requests

3 participants