Skip to content

If blocks raise parse error in attributes #1130

Closed
@eyeseast

Description

@eyeseast

I've run into this a couple times where I want to conditionally add a class name, but svelte raises a ParseError when I try to use an if block inside class.

Here's a broken example: https://svelte.technology/repl?version=1.53.0&gist=287434fece22488b8af3aba0edb73988

Using a ternary works: https://svelte.technology/repl?version=1.53.0&gist=67ccedb4c7cc8e661bc61bb75c40e50c

This may be simply a documentation issue. Using a ternary is fine, but I forget and run into that same error every time.

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