Skip to content

Bound values do not update after element.setRangeText #15774

@jstrieb

Description

@jstrieb

Describe the bug

Calling element.setRangeText on an element with a bound value does not result in the bound value being updated. I would instead expect the bound, reactive variable to update whenever the element's value changes.

Reproduction

https://svelte.dev/playground/e55287e10519482d81dd70a1fbf47ad4?version=5.27.0

<script>
	let value = $state();
	let textarea = $state();

	function prependEquals() {
		textarea.setRangeText("=", 0, 0, "end");
		console.log(textarea.value, value);
	}
</script>

<p>Value: {value}</p>
<textarea bind:this={textarea} bind:value></textarea>
<button onclick={prependEquals}>Prepend "="</button>

System Info

System:
  OS: Linux 6.5 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
  CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Memory: 10.30 GB / 11.44 GB
  Container: Yes
  Shell: 5.2.15 - /bin/bash
Binaries:
  Node: 23.11.0 - /usr/local/bin/node
  Yarn: 1.22.22 - /usr/local/bin/yarn
  npm: 10.9.2 - /usr/local/bin/npm
npmPackages:
  svelte: ^5.27.0 => 5.27.0

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