joy-framework / joy

A full stack web framework written in janet
https://joy.swlkr.com
MIT License
537 stars 30 forks source link

Too many arguments for HTML elements causes them to get dropped silently #56

Closed goto-engineering closed 4 years ago

goto-engineering commented 4 years ago

When I put too many arguments to a HTML structure, they get eaten without any error:

[:h1 "You found joy!" "this" "is" "bob" 2]

Only <h1>You found joy!</h1> is being rendered, the rest just gets dropped. Looks like in html.janet in create-children only the first child is used if it's a string or number. The rest just gets dropped.

Should probably show some kind of warning, or even error? I found out accidentally when I put some text in the wrong place and it wouldn't show up.

This code change doesn't really address the issue well, just kind of a proof of concept of how it could be done. Open to suggestions or if there's a better way to handle it. This feels.. not systematic.

swlkr commented 4 years ago

Yeah I’ve had this problem since I started this project. I tried to fix it a few times but wound up just wrapping text in spans haha

I should really look at how hiccup solves it.

Throwing a warning is better than ignoring for now though

swlkr commented 4 years ago

I came up with something that isn't the best, but it does handle this case:

https://github.com/joy-framework/joy/commit/f117a28fb909f737f7906a303d36687777ea5594