Make dynamic elements context-aware & compositional
MonoidMusician opened this issue · comments
Currently, the dynamic elements like envy
, dyn
, switcher
are not compositional because they insert nodes into their parent without regard to what other children would be there. This means they always end up after the other children:
bussed \p e ->
D.span_
[ switcher
(if _ then text_ "Mysteriously after" else text_ "Obviously before")
(bang false <|> true <$ e)
, D.button
(bang (D.OnClick := p unit))
[ text_ "Misplace" ]
]
(Similar issue with envy $ map
instead of switcher
, and similar issues with dyn
, &c. And it gets worse if D.span_
is replaced with fixed
– then it even leaks into the parent of the above bussed node.)
We need to find a way to make them context-aware, probably by tracking how many children come before and after them (dynamically, since it may change with other nodes).
If we insert an empty element, ie <input type="hidden" value="fooooo"/>
every time a dyn
is created, then we can grab that element and use it as a reference for all child insert/delete/move operations.
Fixed now that Domable
is a monoid.