browser
browser copied to clipboard
Browser.Dom.NotFound is not a function
Hi @evancz, I've found something that looks like mistake of generated JS code. I'm not sure that this module is right place where I should leave my issue, but I got the problem exactly with Browser.Dom
.
The problem
Elm complier unbox things like type Height = Height Float
to just be a float at runtime. Constructor of type just replaced with identity
function under hood. In case with Browser.Dom.NotFound
the initialisation of NotFound
constructor is placed before initialisation of identity
function, so elm$browser$Browser$Dom$NotFound
goes to be undefined
when it called.
Everything works good when elm$core$Basics$identity
is moved to start of generated file.
Environment
- macOS Hight Sierra (10.13.6)
- Google Chrome (71.0.3578.98)
- elm (0.19)
- build must be run with
--optimize
flag
SSCCE
module Main exposing (main)
import Browser
import Browser.Dom
import Html exposing (text)
import Task
main : Program () () ()
main =
Browser.element
{ init =
\_ ->
( ()
, Task.attempt (\_ -> ()) (Browser.Dom.focus "null_node")
)
, view = \_ -> text "Hello cruel world!"
, update = \_ _ -> ( (), Cmd.none )
, subscriptions = \_ -> Sub.none
}