Skip to content

Spread props cause unnecessary changes #3289

@Rich-Harris

Description

@Rich-Harris

Describe the bug

Inline expressions are re-evaluated when setting spread props on a component.

To Reproduce

https://svelte.dev/repl/38ab6eb9233a4d8c97e67d576e063109?version=3.6.8

Expected behavior

Waggling the slider should only cause a to show up as having changed. With the spread version, c also appears to have changed.

Severity

Mildly annoying. Could result in incorrect behaviour (as opposed to mere redundant work)

Additional context

This could be fixed like so:

var nested1_changes = (changed.x || changed.a || changed.b) ? get_spread_update(nested1_spread_levels, [
  (changed.x) && ctx.x,
  (changed.a) && { a: ctx.a },
  (changed.b) && { b: ctx.b },
-  { c: [1] },
-  { d: "string" }
+  nested1_spread_levels[3],
+  nested1_spread_levels[4]
]) : {};
nested1.$set(nested1_changes);

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