Skip to content

Cannot have an unclosed HTML element inside an #if block #3913

@calder12

Description

@calder12

Describe the bug
You cannot have an unclosed HTML element inside an if block. Meaning you couldn't do conditional div tags in a loop for example

{#each things as thing, index}
  {#if index % 10 === 0}
    <div class="new-div">
  {/if}
  Some other content
  {#if index % 10 === 0}
    </div>
  {/if}
{/each}

That code is a bad example, but it should create a new div every tenth element. Instead it throws an error because the first if block has the unclosed div in it.

This however works fine

{#each things as thing, index}
  {#if index % 10 === 0}
    <div class="new-div"></div>
  {/if}
{/each}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions