Replies: 2 comments
-
|
I think the code linked would generate valid html but it might not play well with svelte internals. Or it might be a false positive. Either way, if you goal is to generate one div for each item in the list, you could get the same thing by putting the whole div in the each block. <script>
const whatever = [];
</script>
<nav>
{#each whatever as element}
<div>
</div>
{/each}
</nav> |
Beta Was this translation helpful? Give feedback.
-
|
This is by design. Svelte components get parsed into trees of nodes; it's not a templating engine with ad-hoc open and close tags that happen to form a node after This would also not work since you can't have an "opening tag" and a separate "closing tag": <div>
{#if foo}
<a href={foo}>
{/if}
Some content
{#if foo}
</a>
{/if}
</div> |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I close and open tags in a loop and Svelte tells me I "attempted to close an element that was not open". Which is wrong.
I see no reason this should throw an
element_invalid_closing_tagerror:https://svelte.dev/playground/327e4b2691f44481ad0498cd9ab4d315?version=latest
Is this a bug in Svelte?
Beta Was this translation helpful? Give feedback.
All reactions