Skip to content

Custom element props not changeable after assigned value inside component #12766

Closed
@satouriko

Description

@satouriko

Describe the bug

Once the prop is assigned inside the component, i.e.

<script lang='ts'>
  let {
    value = '',
  }: {
    value: string;
  } = $props();

  function oninput(e: Event) {
    const target = e.target as HTMLInputElement;
    value = target.value;
  };
</script>

<input
  {value}
  oninput={e => oninput(e)}
/>

The prop wouldn't be able to change outside the component anymore, for instance

const ele = document.querySelector('my-custom-element')
ele.value = 'hello world'
console.log(ele.value) // still previous value!!!

Reproduction

https://github.com/satouriko/svelte-custom-element-bug
Click the button, and the input will get filled "hello world"
After inputting something into the input with keyboard, click the button again, the input value wouldn't change to "hello world"

Logs

No response

System Info

Svelte 5
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36'

Severity

blocking all usage of svelte

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions