-
Notifications
You must be signed in to change notification settings - Fork 214
Fix duplicated elements on hydration #306
base: master
Are you sure you want to change the base?
Conversation
thanks for tracking this down. I wonder if the better fix wouldn't be to wait to call |
Huh. What exactly needs to wait for what - and what needs to be fixed - now that Sapper is using |
Defer or not doesn't seem to affect the hydration/duplication problem unfortunately. I'm not sure why because spec says that deferred scripts are Why is the window load event preferred over moving scripts to the end of the body? Just curious. Also, sorry for the poor "gitfu". I'm learning as I go. Any pointers are appreciated! |
The the script is encountered soon and can start being parsed sooner. Probably doesn't make much of a difference with the small document size, but it is better practice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also questioning now whether the document not being loaded yet would result in the behavior being seen. If you try to create a Svelte app when the target element is present you get the message 'target' is a required option
, so it wouldn't end up creating them twice and I don't think it's the case that the script is being run before the target element is present unless I'm missing something
My original hypothesis may be totally incorrect, but the two fixes below do resolve the issue we're seeing. Now the question is why. Do you think Chrome's disk cache retrieval could be at play here? As in the cached resource not being deferred but being retrieved and evaluated before it needs to be? Brief summary of observations
Working Fixes
|
Fixes a problem where elements were being duplicated upon re-hydration on slower connections. See sveltejs/sapper#1725