PlutoHTMLElement and PlutoHTMLElementList
What
This replaces PlutoRunner.DivElement with two new primitives: PlutoHTMLElement and PlutoHTMLElementList.
Why
The problem with DivElement are
- It's always a div
- There is no way to have keyed children
How
I try to fix that by
- Making
PlutoHTMLElementvery generic. It basically takes all the same arguments as aPreact.createElementcall and passes these on directly. It does some special handling for children, more on that later. - Making
PlutoHTMLElementList.PlutoHTMLElementListtakes aDict{String,Any}(!!) where every key is the key prop the child will get on the Preact side. This allows for creating changing lists that preserve identity.
It does contain a polyfill for DivElement based on PlutoHTMLElement, so it doesn't break current PlutoUI.Experimental.Layout uses.
Todo
- [ ] Make sure elements refresh when cell is explicitly re-run (currently some inputs keep their value)
- [ ] Experiment and design the way the identities get preserved (I don't really get yet what parts we want and can make reactive)
- [ ] What to do about children!!! As I mentioned before, we apply special handling to the
childrenprop, which we wrap in Pluto-show-thingies. One problem is, (p)react components often use different props for renderable stuff (title,body,icon). Is there a way we can figure out what props we should wrap in Pluto-show-thingies?
Try this Pull Request!
Open Julia and type:
julia> import Pkg
julia> Pkg.activate(temp=true)
julia> Pkg.add(url="https://github.com/fonsp/Pluto.jl", rev="PlutoHTMLElement-and-PlutoHTMLElementList")
julia> using Pluto
@dralletje Can you make a TODO list?
From @fonsp during a call: Why are there two primitives rather than one. This is a good question, I'll ponder it a bit. I still think we need two primitives, but they might be different ones.
Can you make the changes to the preact import on main instead?