[FIX] t-out: does not crash when outputting null

Before this commit, doing `t-out="null"` would crash, since the
safeOutput function would assume that it is a block, thanks to the fact
that `typeof null === 'object'`.

We handle here the null value just as if it was undefined: it outputs an
empty string.
This commit is contained in:
Géry Debongnie
2023-04-24 16:09:10 +02:00
committed by Sam Degueldre
parent 1784a98b2c
commit f9d810a42f
3 changed files with 18 additions and 1 deletions
+1 -1
View File
@@ -134,7 +134,7 @@ class LazyValue {
* Safely outputs `value` as a block depending on the nature of `value`
*/
export function safeOutput(value: any, defaultValue?: any): ReturnType<typeof toggler> {
if (value === undefined) {
if (value === undefined || value === null) {
return defaultValue ? toggler("default", defaultValue) : toggler("undefined", text(""));
}
let safeKey;