rtfeldman / elm-in-action

Resources for the Elm In Action book.
166 stars 33 forks source link

Different navLink implementations #48

Open kantuni opened 4 days ago

kantuni commented 4 days ago

In 8.1.2, under sections Passing "Named Arguments" and Using classList the navLink function is defined as follows

navLink targetPage { url, caption } =
    li [ classList [ ( "active", page == targetPage ) ] ]
        [ a [ href url ] [ text caption ] ]

However, under section Using Debug.log to tell when a function has been run the navLink function has a different implementation.

navLink route { url, caption } =
    li [ classList [ ( "active", isActive { link = route, page = Debug.log "Rendering nav link with" page } ) ] ]
        [ a [ href url ] [ text caption ]
        ]

It's using a function that hasn't been defined yet.

It should be

navLink targetPage { url, caption } =
    li [ classList [ ( "active", Debug.log "Rendering nav link with" page == targetPage ) ] ]
        [ a [ href url ] [ text caption ] ]