New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime `TypeError: domNode.elm_event_node_ref is undefined` when using multiple Html.App.map calls #615

Closed
niksilver opened this Issue May 19, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@niksilver

niksilver commented May 19, 2016

When I compile and run the following code (Elm 0.17) it results in repeated TypeError: domNode.elm_event_node_ref is undefined (Firefox 46.0.1, Windows 10) or Uncaught TypeError: Cannot set property 'tagger' of undefined (Chrome 50.0.2661.102 m, Windows 10) in the web console. Error is in app.js line 6941.

Main.elm:

import Html exposing (Html)
import Html.App exposing (program)
import Svg exposing (Svg, svg, g, circle)
import Svg.Attributes exposing (cx, cy, r)
import Time exposing (Time, millisecond)

type alias Model = List String

type Msg = Ping

main : Program Never
main =
    program
        { init = ([], Cmd.none)
        , view = view
        , update = (\msg model -> ([], Cmd.none))
        , subscriptions = subscriptions
        }

view : Model -> Html Msg
view model =
    svg [] [ view2 0, view2 0 ]
        |> Html.App.map identity
        |> Html.App.map identity

view2 : Int -> Svg Msg
view2 dummy =
    groupedCircle
        |> Html.App.map (always Ping)

groupedCircle : Svg Msg
groupedCircle =
    g [] [circle [cx "100", cy "100", r "200"] []]

subscriptions : Model -> Sub Msg
subscriptions model =
    Time.every (30 * millisecond) (always Ping)

index.html:

<html>
<head>
    <script type="text/javascript" src="app.js"></script>
</head>

<body>
    <div id="app"></div>
</body>

<script type="text/javascript">
    var appDiv = document.getElementById('app');
    Elm.Main.embed(appDiv);
</script>
</html>

When we load index.html the web console shows the TypeError above, once per Ping (i.e. once every 30 ms).

I realise the above code looks odd, but it's actually a cut-down version of a real application which I'm trying to convert from Elm 0.16 to 0.17. So it is based on a real use case.

I've tried to reduce the code even further, but cannot do it while still demonstrating the TypeError. Here are some ways I've tried to reduce the above code, but unsuccessfully, because each of these changes actually eliminates the error - even though none of these should alter the core logic:

  • In function view change [ view2 0, view2 0 ] to a singleton [ view2 0 ]
  • in function view remove one or both of the Html.App.map identity lines
  • Change the signature of view2 from Int -> Svg Msg to just Svg Msg, thus removing the dummy argument
  • In function view2 change the call of Html.App.map (always Ping) to Html.App.map identity
  • In function view2 remove the call of Html.App.map (always Ping) entirely, so that the function just returns groupedCircle
  • Change function groupedCircle so that it doesn't use Svg.g and just returns the SVG circle directly

Thanks in advance.

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender May 19, 2016

Contributor

@niksilver, can you please check whether yours is essentially the same issue as https://github.com/elm-lang/virtual-dom/issues/21, and if so, close here?

Contributor

jvoigtlaender commented May 19, 2016

@niksilver, can you please check whether yours is essentially the same issue as https://github.com/elm-lang/virtual-dom/issues/21, and if so, close here?

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender May 19, 2016

Contributor

Or better yet, look out for when the fix to https://github.com/elm-lang/virtual-dom/issues/21 is released, and then check whether it fixes your case as well?

Contributor

jvoigtlaender commented May 19, 2016

Or better yet, look out for when the fix to https://github.com/elm-lang/virtual-dom/issues/21 is released, and then check whether it fixes your case as well?

@niksilver

This comment has been minimized.

Show comment
Hide comment
@niksilver

niksilver May 19, 2016

@jvoigtlaender It looks incredibly similar, particularly the reference to "The repeated App.map is necessary to trigger the error". It makes good sense for me to look out for a fix to elm-lang/virtual-dom#21 and update this issue then.

niksilver commented May 19, 2016

@jvoigtlaender It looks incredibly similar, particularly the reference to "The repeated App.map is necessary to trigger the error". It makes good sense for me to look out for a fix to elm-lang/virtual-dom#21 and update this issue then.

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz May 19, 2016

Member

Don't want to keep multiple issues for the same thing. This is definitely a duplicate.

Member

evancz commented May 19, 2016

Don't want to keep multiple issues for the same thing. This is definitely a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment