Skip to content

Getter function runs multiple times when bound to an input #14963

@alialaa

Description

@alialaa

Describe the bug

I am not sure if this is a bug or normal behavior for some reason. But in this example, initially the getter function for value runs 3 times. And when the second input is updated, the getter function runs 2 times. Even though left.value is only used once in the template.

This does not happen if bind: is not used:

<label>
	<input type="number" value={left.value} oninput={(e) => {
			left.value = e.target.value;
	}} max={total} />
</label>

Reproduction

https://svelte.dev/playground/a2c1809d94f445308e65df38eb24cf8a?version=5.17.1

Logs

No response

System Info

System:
    OS: macOS 15.1.1
    CPU: (12) arm64 Apple M3 Pro
    Memory: 100.69 MB / 18.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.18.0 - ~/.nvm/versions/node/v20.18.0/bin/node
    npm: 10.8.2 - ~/.nvm/versions/node/v20.18.0/bin/npm
    Watchman: 2024.12.02.00 - /opt/homebrew/bin/watchman
  Browsers:
    Chrome: 131.0.6778.264
    Safari: 18.1.1
  npmPackages:
    svelte: ^5.0.0 => 5.17.1

Severity

annoyance

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