Skip to content

Commit

Permalink
md: support undefined/null (parcel-bundler#5928)
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic authored Feb 28, 2021
1 parent 8a4fa3e commit 349302c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/core/diagnostic/src/diagnostic.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export function md(
let param = params[i];
result.push(
strings[i],
param[mdVerbatim] ? param.value : escapeMarkdown(`${param}`),
param?.[mdVerbatim] ? param.value : escapeMarkdown(`${param}`),
);
}
return result.join('') + strings[strings.length - 1];
Expand Down
4 changes: 4 additions & 0 deletions packages/core/diagnostic/test/markdown.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,8 @@ describe('md tagged template literal', () => {
};
assert.strictEqual('Test: b', md`Test: ${v}`);
});

it('supports null and undefined', () => {
assert.strictEqual('Test: undefined null', md`Test: ${undefined} ${null}`);
});
});

0 comments on commit 349302c

Please sign in to comment.