1
1
mirror of https://github.com/srid/ema.git synced 2024-11-25 20:12:20 +03:00

Re-evaluate script tags on reload (#45)

This commit is contained in:
Sridhar Ratnakumar 2021-06-09 21:57:30 -04:00 committed by GitHub
parent 18a6acd41a
commit 66a679700a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -3,7 +3,9 @@
## Unreleased (0.2.0.0)
- TODO(doc) runEma's action gets the `CLI.Action` as argument, to prevent the `gen` command from needing to monitoring files.
- Handle invalid routes gracefully without breaking websocket
- Live Server
- Handle invalid routes gracefully without breaking websocket
- Re-add `<script>` tags on hot reload
- `Asset` type
- Introduce the `Asset` type to distinguishing between static files and generated files. The later can be one of `Html` or `Other`, allowing the live server to handle them sensibly.
- `Ema` typeclass:

View File

@ -198,7 +198,7 @@ wsClientShim =
morphdom(elm, html);
};
// FIXME: Can't make this work with tailwind shim
// FIXME: This doesn't reliably work across all JS.
function reloadScripts(elm) {
Array.from(elm.querySelectorAll("script")).forEach(oldScript => {
const newScript = document.createElement("script");
@ -294,8 +294,8 @@ wsClientShim =
document.location.href = evt.data.slice("REDIRECT ".length);
} else {
setHtml(document.documentElement, evt.data);
reloadScripts(document.documentElement);
window.scrollTo({ top: 0});
// reloadScripts(document.documentElement);
watchCurrentRoute();
};
};