Skip to content

class: directives do not work when used on elements with both bind:this and prop spreading #2707

@mtlewis

Description

@mtlewis

I've noticed that when elements have the bind:this directive as well as props spread onto the element, class: directives do not result in the appropriate class being applied. This can be worked around by using a class attribute with an expression (e.g. class={primary ? 'primary' : ''} works, but class:primary does not).

Here's a demonstration of the issue. You'll note that the anchor will be green as expected if you do any of the following three things:

  • delete line 3 (bind:this={anchor}),
  • delete line 4 ({...{ other: 'props' }}), or
  • change line 2 to class={primary ? 'primary' : ''}.

Thanks for all the great work you've done on this library!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions