Kasey Speakman
2017-05-09 20:00:29 UTC
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
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 elm-discuss+***@googlegroups.com.
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 elm-discuss+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.