-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/check content type #1754
Fix/check content type #1754
Conversation
|
@@ -20,7 +20,7 @@ const { privateRenderMarkdownDoNotUse: renderMarkdown } = (Astro as any); | |||
if (!content) { | |||
const { privateRenderSlotDoNotUse: renderSlot } = (Astro as any); | |||
content = await renderSlot('default'); | |||
if (content.trim().length > 0) { | |||
if (content !== undefined && content !== null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense to me. Obviously we’d need to test this, but I can see the logic in just assuming strings are correct, and handling non-strings like you’re doing here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good so far! Happy to review when this isn’t a draft PR.
it("doesn't occurs TypeError when no elements", async () => { | ||
const html = await fixture.readFile('/no-elements/index.html'); | ||
// render html without error | ||
expect(!!html).to.equal(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(!!html).to.equal(true); | |
expect(html).to.be.ok; |
Same test; just a little easier to read.
* test: add test case * fix: add type guard insted of content.trim().length > 0 * test: fix test
Changes
resolve #1753
I added type guard to avoid TypeError when describing
Markdown
component with no children.Testing
I added the test case about this.
Docs
bug fix only