Ah yes, that's another good workaround. It's definitely not rendering as I would expect. Probably a performance optimization that's gone awry.
I also tried download False, but that renders download="false". Which also triggers a download (!) instead of opening normally, so the Elm's download API must be askew. On Tuesday, May 9, 2017 at 3:28:04 PM UTC-5, Witold Szczerba wrote: > > This is surprising… Looks like DOM↔VDOM diff does not remove missing (but > attached once) attributes? Or it ignores them because it does not want to > be too invasive? > > As a other workaround, you can have always two amchor tags: one with > "target", one without, and just switch the visibility of them (the > "onClick" could be attached to the wrapping span, or both can have same > one). > > Regards, > Witold Szczerba > > On Tue, May 9, 2017 at 10:00 PM, Kasey Speakman <[email protected] > <javascript:>> wrote: > >> Hi, maybe someone has run into this. >> >> I'm noticing that download and target attributes are not getting removed >> from links even though subsequent renders are omitting them. >> >> Using this test code on http://elm-lang.org/try: >> >> import Html exposing (a, text, beginnerProgram) >> import Html.Events exposing (onClick) >> import Html.Attributes exposing (target, download) >> >> main = >> beginnerProgram { model = False, view = view, update = update } >> >> view model = >> a >> [ onClick Toggle >> , if model then >> target "_blank" >> else >> download True >> ] >> [ text "click" ] >> >> type Msg = >> Toggle >> >> update msg model = >> case msg of >> Toggle -> >> not model >> >> >> The initial view renders download="true". >> >> First click renders download="null" target="_blank". In Chrome at least, >> blank target is ignored and file is downloaded anyway simply for the >> presence of download attribute. >> >> Second click renders download="true" target. >> >> I thought omitting the attribute would result in it being absent in the >> rendered HTML, but not so. >> >> *Well, after I typed this out...* >> >> I found two work-around. >> >> 1) Wrap in a different parent element for each. For example, use div for >> one and span for the other. >> 2) Using Html.Keyed.node to put an identity on each. >> >> Kasey >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Elm Discuss" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "Elm Discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
