Skip to content

Two-Way Binding With Native Components Not In Sync With Attribute #5705

Closed
@munawarb

Description

@munawarb

I'm writing a native web component using Svelte which is a wrapper around an edit field:

<script>
export let value = "Default Value";
</script>
<main>
<input type="text" bind:value={value} />
</main>

I can set the value, which properly updates the textbox.

I then type stuff into the textbox, which updates value, which I can verify by using document.getElementById("my-component").value.

However, when I get the value of my component using document.getElementById("my-component").getAttribute("value"), it returns the last value that I set using setAttribute("value", "Some other value").

It doesn't return the actual value property on the component that got updated when I typed stuff into the textbox.

How can I keep the attribute and property in sync, or is there not a way to do this?

This is when I compile my component as a native web component.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions