Fix JS output export when data includes structs

This commit is contained in:
Jonatan Kłosko 2024-05-24 23:00:12 +07:00
parent a0a3f548fe
commit ef25a2e24b
2 changed files with 7 additions and 3 deletions

View file

@ -413,7 +413,7 @@ defmodule Livebook.LiveMarkdown.Export do
end
end
defp ensure_order(%{} = map) do
defp ensure_order(%{} = map) when not is_struct(map) do
map
|> Enum.sort()
|> Enum.map(fn {key, value} -> {key, ensure_order(value)} end)

View file

@ -903,7 +903,11 @@ defmodule Livebook.LiveMarkdown.ExportTest do
ref: "1",
pid:
spawn_widget_with_data("1", %{
spec: %{"height" => 50, "width" => 50},
spec: %{
"height" => 50,
"width" => 50,
"data" => %{"x" => 1, "y" => 1, "date" => ~D[2024-05-24]}
},
datasets: []
}),
assets: %{archive_path: "", hash: "abcd", js_path: "main.js"}
@ -929,7 +933,7 @@ defmodule Livebook.LiveMarkdown.ExportTest do
<!-- livebook:{"output":true} -->
```vega-lite
{"height":50,"width":50}
{"data":{"date":"2024-05-24","x":1,"y":1},"height":50,"width":50}
```
"""