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

Markdown Preview update sometimes breaks down in the restored preview #345

Closed
yhatt opened this issue Apr 21, 2022 · 5 comments · Fixed by #347
Closed

Markdown Preview update sometimes breaks down in the restored preview #345

yhatt opened this issue Apr 21, 2022 · 5 comments · Fixed by #347
Labels
bug Something isn't working

Comments

@yhatt
Copy link
Member

yhatt commented Apr 21, 2022

Version of Marp Tool

Marp for VS Code v1.5.1

Operating System

Windows

Environment

  • OS version: Windows 10
  • VS Code version (Marp for VS Code): v1.67-insider

How to reproduce

  1. Create a new Markdown file (Don't need that is Marp document)
  2. Type in some characters and open preview
  3. Choose "Developer: Reload Window" from the command palette.
  4. Add new characters to Markdown one by one

Expected behavior

Replaces the current Markdown preview to the updated contents.

Actual behavior

The outdated preview contents will keep from the second updation, and new contents will insert to the last of preview.

Additional information

I guess Marp extension is causing failed updation of the preview because could not reproduce that if disabled Marp extension.

It is especially reproducible when edited Markdown at the same timing as showing restored preview. (At that time, I think script for VS Code's preview has been loaded, but a contribution script from Marp may not be loaded yet)

@yhatt yhatt added the bug Something isn't working label Apr 21, 2022
@eyssette
Copy link

Same problem here.

Marp for VS Code v1.5.1
Operating System : Mac
Environment : Mac OS Monterey 12.2.1

@yhatt

This comment was marked as outdated.

@yhatt yhatt added the help wanted Extra attention is needed label Apr 22, 2022
@yhatt
Copy link
Member Author

yhatt commented Apr 22, 2022

I finally found out an accidental collision of minified global variable, between Marp's script for preview and VS Code's preview script.

In the context of morphdom, used by VS Code for incremental updation of DOM, a global variable ELEMENT_NODE from morphdom must be 1. It has been defined as minimized global variable j in Markdown preview.

On the other hand, Marp's minified preview script also has defined j global variable as Object.defineProperty. If Marp script was loaded after VS Code's preview script, Marp will break morphdom by accidential overloading!

Fortunately it is easy to fix: Set format constructor option for EsbuildMinifiyPlugin as 'iife'. (privatenumber/esbuild-loader#139 (comment))

@jarodtang

This comment was marked as off-topic.

@yhatt

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants