Open CNSeniorious000 opened 1 month ago
This behaviour seems fixed in svelte 5 so i don't know if it will be back ported to svelte 4.
I don't get this. In the reproduction Container
does nothing except rendering its children. What should update in there?
inside
in Content
is true
.
I also modified Content
to check if the .parentElement
of the <pre>
is the same as ref
, and that is true
as well.
The element: {ref} Is it inside the document? {inside} Is pre.parentElement === ref {isSame} (it should be!)```
I don't get this. In the reproduction
Container
does nothing except rendering its children. What should update in there?inside
inContent
istrue
. I also modifiedContent
to check if the.parentElement
of the\<pre\>
is the same asref
, and that istrue
as well.Changed
Content.svelte
<script> export let ref; let pre $: inside = ref && document.contains(ref); $: isSame = ref && pre && pre.parentElement === ref; </script> <pre bind:this={pre}> The element: {ref} Is it inside the document? <span style:color={inside ? "green" : "red"}>{inside}</span> Is pre.parentElement === ref <span style:color={isSame ? "green" : "red"}>{isSame}</span> (it should be!) </pre> <style> span { font-weight: bold; } </style>
To see the behavior you should modify the readme to trigger HMR.
To see the behavior you should modify the readme to trigger HMR.
Oh, this is a HMR issue. Thanks for the explanation.
Sorry for missing description. This reproduction is a simplified one. In my realworld use case, the Container
component depends on some useful files. Changing them will trigger an HMR which behaves wrongly. In this demo, I change that to a useless import to README.md
, which may be confusing.
Describe the bug
When
Container
got updated, thediv
seems to be a new one, but theref
points to the old one.Reproduction
Logs
No response
System Info
Severity
annoyance