markdown-up 3.3.5 → 3.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/app.js +10 -0
  2. package/package.json +1 -1
package/lib/app.js CHANGED
@@ -108,6 +108,7 @@ export class MarkdownUp {
108
108
  this.url = (options !== null ? options.url : null) ?? 'README.md';
109
109
  this.runtimeWindowResize = null;
110
110
  this.runtimeTimeoutId = null;
111
+ this.renderCount = 0;
111
112
  }
112
113
 
113
114
 
@@ -121,6 +122,9 @@ export class MarkdownUp {
121
122
 
122
123
 
123
124
  async render(forceRender = false) {
125
+ // Increase the render count enable so we can detect a render the middle of a runtime update
126
+ this.renderCount += 1;
127
+
124
128
  // Parse the hash parameters and render the application element model
125
129
  let result;
126
130
  let isError = false;
@@ -427,12 +431,18 @@ export class MarkdownUp {
427
431
 
428
432
  // Create the markdown-script runtime
429
433
  const runtime = new MarkdownScriptRuntime(scriptOptions);
434
+ const {renderCount} = this;
430
435
  scriptOptions.globals = {...markdownScriptFunctions};
431
436
  if (this.globals !== null) {
432
437
  Object.assign(scriptOptions.globals, this.globals);
433
438
  }
434
439
  scriptOptions.runtime = runtime;
435
440
  scriptOptions.runtimeUpdateFn = () => {
441
+ // Did a render occur in the middle of this runtime update?
442
+ if (this.renderCount !== renderCount) {
443
+ return;
444
+ }
445
+
436
446
  // Did script set the document title?
437
447
  if (runtime.documentTitle !== null) {
438
448
  this.window.document.title = runtime.documentTitle;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "markdown-up",
4
- "version": "3.3.5",
4
+ "version": "3.3.6",
5
5
  "description": "MarkdownUp is a Markdown viewer",
6
6
  "keywords": [
7
7
  "markdown",