Skip to content

Extraneous DOM nodes created when using computed property with {#each} -loop #1712

Closed
@arggh

Description

@arggh

I bumped into a weird bug. I was using a computed property in an each loop to display either 3 or 2 items. This was implemented by either returning an array with 3 items, or a two item slice of the same array, based on a boolean value in component's state. When toggling state so that the computed property returns an array with two items instead of three, Svelte just keeps adding extra elements to DOM. If I keep toggling the state, I will end up with ∞ elements.

REPL Example: https://svelte.technology/repl?version=2.13.2&gist=56be5b00c35d6288467d2ab6db2d1cc0

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