Skip to content

[Svelte5] Object are not always reactive on template #13525

@adiguba

Description

@adiguba

Describe the bug

Hello,

I am still confused about the specific behavior of objects in templates.

Since the different functions like set_text(), set_value(), set_attribute compare the value ​​before applying the change.
So objects are only reactive when :

  • They are reassigned.
  • They are concatenated with a string.
  • We call toString() explicitly.

Exemple with a reactive object object :

<!-- This is reactive : -->
<div title="the title : {object}">Text content : {object}</div>
<!-- This is not reactive : -->
<div title={object}>{object}</div>

Reproduction

Click on add to Array to push an element into the array.
Some syntaxes are reactive, others are not...

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