elm-graphics
elm-graphics copied to clipboard
Element.show breaks program when run at initialization time in compiled html
Compiling this program:
import Html exposing (div)
import Html.App exposing (beginnerProgram)
import Element exposing (show, toHtml)
main =
beginnerProgram
{ model = show "Test"
, view = \model -> div [] [ toHtml model ]
, update = \_ model -> model
}
with Elm 0.17's elm-make and then opening the produced index.html leads to a blank screen instead of displaying the "Test" string.
If one instead moves the show call to inside the view function:
{ model = "Test"
, view = \model -> div [] [ toHtml (show model) ]
then the program functions correctly.
And even the original program (which fails when compiled to .html) works correctly in elm-reactor, as well as when compiled to .js and called from some separate .html file, as well as if one manually takes the original compiled .html file and moves the <script>...</script> element with the compiled source from inside <head>...</head> to inside <body>...</body>.
Also ran into this just now (when adding a Text Element); fix in https://github.com/evancz/elm-graphics/pull/20