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

Preventable runtime error caused by setAttribute '' #179

Closed pfiadDi closed 2 years ago

pfiadDi commented 2 years ago

This causes a runtime error loop:

Html.Attributes.attribute "" ""

The error: Main.elm:2872 Uncaught DOMException: Failed to execute 'setAttribute' on 'Element': '' is not a valid attribute name. at _VirtualDom_applyAttrs (http://localhost:5000/index.975ef6c8.js:2497:52)

This could be prevented by the compiler by not accepting empty "" as attribute arguments

pfiadDi commented 2 years ago

Same issue as #141

evancz commented 2 years ago

The compiler does not check specific values. It only checks types like String and Int, not whether a specific function gets "" or "abc" or whatever else. I believe there are other compilers that do that sort of thing though.

Anyway, we can track this one with #141. Thank you for the report!