elm / virtual-dom

The foundation of HTML and SVG in Elm.
https://package.elm-lang.org/packages/elm/virtual-dom/latest
BSD 3-Clause "New" or "Revised" License
209 stars 80 forks source link

Bug when diffing an `a` html element which contains an `href` attribute. #109

Closed amilner42 closed 7 years ago

amilner42 commented 7 years ago

Problem

This bug is very easy to recreate and observe, I made a very basic ellie here

Long story short, here is what happens step-by-step:

  1. Start with an a element with no href, like a [] [], it can't be clicked.
  2. Toggle and switch to another a with an href like: a [ href "https://google.com" ] []
    • So far so good, we can now click the a and go to google.
  3. Toggle back to an a with no href, but now instead of having the original a [] [] (which is what we expect) we get the following html: <a href="">no href</a>. This is obviously problematic.

Workaround

  1. Use Html.keyed and use dif keys, this will force a total reset.
process-bot commented 7 years ago

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

amilner42 commented 7 years ago

(Issue closed to be moved to elm-lang/html)