-
Notifications
You must be signed in to change notification settings - Fork 67
Description
SSCCE:
module Main exposing (main)
import Browser
import Html
import Html.Events
type Msg
= Pärtan SubMsg
type SubMsg
= Ärtan
main =
Browser.sandbox
{ init =
{ startsWithAscii = Pärtan Ärtan
, startsWithUnicode = Ärtan
}
, update = always identity
, view =
\_ ->
Html.button [ Html.Events.onClick (Pärtan Ärtan) ]
[ Html.text "Click me, then open the debugger" ]
}
Notice how:
- The messages history on the left correctly displays
Pärtan Ärtan. - The current message on the right instead displays
Pärtan <internals>. - The model on the right displays
Pärtan <internals>and<internals>.
The reason it works in the messages history but not in the main view is because there are two functions that displays Elm values – and only one of them is correct.
-
_Debugger_messageToStringis used for the messages history. In short, it considers custom types with an ASCII lowercase first letter as internal (such asa3, which is a virtual DOM attribute), and all other custom types as displayable. https://github.com/elm/browser/blob/1.0.2/src/Elm/Kernel/Debugger.js#L356-L376 -
_Debugger_initis used for the main view (both for the message and the model). In short, it kind of does the opposite: It considers a custom type with an ASCII uppercase first letter as displayable, and all other custom types as internal. That is equivalent to the approach in_Debugger_messageToString– but only for ASCII. Elm supports custom type variants that starts with any unicode uppercase letter. https://github.com/elm/browser/blob/1.0.2/src/Elm/Kernel/Debugger.js#L439-L451
The solution is to use the _Debugger_messageToString approach in _Debugger_init too: Hide ASCII lowercase, and display others.
Expected:
