Skip to content

Commit 416684b

Browse files
committed
Fix rendering of null and undefined in #html
1 parent 10d2183 commit 416684b

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
[Squint](https://github.com/squint-cljs/squint): Light-weight ClojureScript dialect
44

5+
## v0.9.176
6+
7+
- Fix rendering of `null` and `undefined` in `#html`
8+
59
## v0.9.175
610

711
- [#747](https://github.com/squint-cljs/squint/issues/747): `#html` escape fix

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "squint-cljs",
33
"type": "module",
44
"sideEffects": false,
5-
"version": "0.9.175",
5+
"version": "0.9.176",
66
"files": [
77
"core.js",
88
"src/squint/core.js",

src/squint/html.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function attr(v) {
6060
}
6161

6262
function toHTML(v, unsafe) {
63-
if (v == null) return;
63+
if (v == null) return '';
6464
if (v instanceof Html) return v;
6565
if (typeof(v) === 'string') return unsafe ? v : safe(v);
6666
if (v[Symbol.iterator]) {

test/squint/html_test.cljs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@
4646
(deftest html-nil-test
4747
(t/async done
4848
(let [js (squint.compiler/compile-string
49-
"(let [p nil] #html [:div p])"
49+
"(let [p nil] #html [:div p js/undefined \"foo\"])"
5050
{:repl true :elide-exports true :context :return})
5151
js (str/replace "(async function() { %s } )()" "%s" js)]
5252
(-> (js/eval js)
5353
(.then
54-
#(is (html= "<div>undefined</div>" %)))
54+
#(is (html= "<div>foo</div>" %)))
5555
(.catch #(is false "nooooo"))
5656
(.finally done)))))
5757

0 commit comments

Comments
 (0)