woutdp / live_svelte

Svelte inside Phoenix LiveView with seamless end-to-end reactivity
https://hexdocs.pm/live_svelte
MIT License
1.2k stars 46 forks source link

Non ASCII encoding #103

Closed drKreso closed 8 months ago

drKreso commented 8 months ago

When I have a non ASCII code in .svelte script. It flickers on first render, as it is wrongly encoded at the start. I was reading up it has to with the fact that Svelte does assumes UTF8 encoding, but browser does not and that I somehow need to manually set this up. Not sure where to look, or if it's something that would fit nicely in this hex.

Refreshig page for dramatic effect :)

https://github.com/woutdp/live_svelte/assets/32063/d17af1b2-c7cf-47ca-b39b-ea08f612273f

Screenshot 2024-01-09 at 11 38 54

This snippet from the image

<table class="table-auto border-separate border-slate-500">
  <caption class="caption-top">
   Status shopping centara na današnji dan
 </caption

Behavior definetly looks like SSR issue, as it gets corrected by client rerender and is not manifesting if I use :ssr=false (but then it flickers due to client render)

drKreso commented 8 months ago

Still not smarter after a whole day of looking into this. So many moving parts :)

I belive it is somewhere in Elixir-NodeJS bridge.

Looks properly encoded in svelte app.js entrypoint as Unicode Character “š” (U+0161)

Screenshot 2024-01-11 at 10 30 53

When called from elixir it gives back garbage

 NodeJS.call!({"server", "render"}, ["OpenToday", %{}, %{}])
Screenshot 2024-01-11 at 10 34 16 Screenshot 2024-01-11 at 10 31 15
drKreso commented 8 months ago

Figured it out.

NodeJS.call!({"server", "render"}, ["OpenToday", %{}, %{}], binary: true)