Skip to content

Prop state on first instance of a custom element are lost when using HMR #21

Closed
@patricknelson

Description

@patricknelson

Describe the bug

When using HMR (i.e. vite in development mode), the first instance of any particular svelte-retag loaded component loses state after the first save. This is likely due to an issue with the props proxy which was setup for lit style lowercase props here: https://github.com/patricknelson/svelte-retag/blob/1.3.1/index.js#L430

Likely a regression from #18.

Reproduction

  1. Setup a component that takes a prop (such as link="https://example.com") called ExampleComponent.svelte and ensure link prop is used somehow in the component
  2. Define a custom element for it in svelte retag (e.g. example-element)
  3. Setup page with <example-element link="https://example.com">
  4. Start up yarn vite to start up dev mode and load page setup in step above
  5. Edit ExampleComponent.svelte

Bug appears when link is now empty.

Logs

No response

System Info

System:
    OS: Linux 5.15 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (16) x64 Intel(R) Core(TM) i7-10875H CPU @ 2.30GHz
    Memory: 3.19 GB / 5.79 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.14.2/bin/yarn
    npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
  Browsers:
    Chrome: 119.0.6045.105
  npmPackages:
    svelte: ^4.2.2 => 4.2.2
    svelte-retag: 1.3.0 => 1.3.0

Severity

annoyance

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions