Closed AleksandrHovhannisyan closed 2 years ago
Yeah, we might need to think a little bigger here. Similar concerns were reported by @j-f1 at #7 too!
Found this excellent helper which seems to work well to rerun scripts
https://github.com/patrick-steele-idem/morphdom/issues/178#issuecomment-652562769
Shipping with 1.0.0-canary.10
Wow, that was quick! Thanks @zachleat!
Describe the bug
I've been test running 2.0.0-canary-10 for a few weeks now on my blog. So far, I'm a BIG fan of the new reload behavior! It makes authoring a much more pleasant experience and is so much faster. That said, I did notice a bug where the hot reload breaks and elements inserted into the page with JavaScript disappear once the hot reload occurs.
Suppose you have this
index.html
in an absolute bare-minimum 11ty project with nothing else:On an initial page load or a manual reload, it works as expected: The user sees
I love 11ty
.If you later edit the file and save it to trigger a rebuild, though, the page reloads and the JavaScript breaks. Now, you only see
I love
.To Reproduce Steps to reproduce the behavior:
yarn
to install dependencies.yarn serve
to start the dev server.I love 11ty
.src/index.html
.I love
.Expected behavior This is somewhat expected because the page didn't actually reload, so the JavaScript doesn't re-run. On the other hand, if the page isn't actually reloading, elements previously inserted by JavaScript should be preserved. It can be a little annoying if you're writing JavaScript and want to see the results since you need to reload the page manually on each refresh. However, so far this has only been a minor annoyance for me.
Screenshots
N/A
Environment: