Skip to content

[Svelte 5] style-directive reactivity problems #9854

@adiguba

Description

@adiguba

Describe the bug

I found two problems with reactivity with the style:property directive.

  1. The style directive is not reactive when used with a function.
    Example :
<div style:background-color={getColor()}>1</div>

I think that the $.style() should be inside a $.render_effect(), but this is not the case.


  1. All the style-directives of an element are re-rendered when one of the state change.
<div style:background-color={color} style:color={randomColor()}>2</div>

randomColor() is not a reactive function, but it's called when the color state is updated.

All the $.style() are inside the same $.render_effect().
I think they should have separate calls...


Perhaps all the $.style() should be called directly, and the $.render_effect() be called inside the $.style() function.

Reproduction

See REPL

Logs

No response

System Info

REPL

Severity

annoyance

Metadata

Metadata

Assignees

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