The <slot> tag is missing the closing slash on the closing tag (</slot>).
Step 2: Validate HTML correctness
Proper closing tags are required; missing slash causes syntax error.
Final Answer:
Missing closing tag slash on <slot> element -> Option B
Quick Check:
Proper closing tags = Missing closing tag slash on <slot> element [OK]
Hint: Always close slot tags properly with [OK]
Common Mistakes:
Ignoring missing slash on closing tag
Thinking fallback must be wrapped in div
Believing extra content after slot is invalid
5. You want a Svelte component to show a default message if no slot content is passed, but also include a button that only appears when slot content is provided. How can you achieve this?
hard
A.
Click me
B. Default message
{#if !$$slots.default}
Click me
{/if}
C. Default message
{#if $$slots.default}
Click me
{/if}
D. Default message
Click me
Solution
Step 1: Use fallback content inside <slot>
Placing 'Default message' inside <slot> ensures it shows if no content is passed.
Step 2: Conditionally show button with $$slots.default
Using {#if $$slots.default} checks if slot content exists, showing button only then.
Final Answer:
<slot>Default message</slot>
{#if $$slots.default}
<button>Click me</button>
{/if} -> Option C