From bf7f72b74bfe8f1706ec764a5fa783b8cc8017c1 Mon Sep 17 00:00:00 2001 From: Harsh Singh <64768386+harshdoesdev@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:35:25 +0530 Subject: [PATCH] prevent undefined from getting printed in markdown text (#1379) * prevents undefined from getting printed in markdown * fix all tests --- fastn-js/js/dom.js | 4 +++- ftd/t/js/21-markdown.ftd | 13 +++++++++++++ ftd/t/js/21-markdown.html | 19 ++++++++++++++++++- ftd/t/js/63-external-js.html | 2 +- 4 files changed, 35 insertions(+), 3 deletions(-) diff --git a/fastn-js/js/dom.js b/fastn-js/js/dom.js index c5b96f41ff..3a772debf4 100644 --- a/fastn-js/js/dom.js +++ b/fastn-js/js/dom.js @@ -1883,7 +1883,9 @@ class Node2 { staticValue = this.#node.innerHTML; } staticValue = fastn_utils.process_post_markdown(this.#node, staticValue); - this.#node.innerHTML = staticValue; + if(!fastn_utils.isNull(staticValue)) { + this.#node.innerHTML = staticValue; + } } else { throw ("invalid fastn_dom.PropertyKind: " + kind); } diff --git a/ftd/t/js/21-markdown.ftd b/ftd/t/js/21-markdown.ftd index 2c33876191..ae5e34ab01 100644 --- a/ftd/t/js/21-markdown.ftd +++ b/ftd/t/js/21-markdown.ftd @@ -3,3 +3,16 @@ # Marked in the browser Rendered by **marked**. + +-- component markdown: +body string text: + +-- ftd.text: +text: $markdown.text + +-- end: markdown + +-- markdown: + +;; COMMENT NEXT LINE +;; Go to the [new page](/new-page/). diff --git a/ftd/t/js/21-markdown.html b/ftd/t/js/21-markdown.html index 65d4513368..a5aaf0d950 100644 --- a/ftd/t/js/21-markdown.html +++ b/ftd/t/js/21-markdown.html @@ -17,7 +17,7 @@