Open loganlinn opened 10 years ago
Shouldn't we be able to do (get-in container (interpose .-children (cursor component)))
?
The cursor, at the moment, consists of the children offsets in the virtual dom. Meaning, it includes composite components that don't have concrete DOMNodes. We are doing the virtual dom equivalent of what you suggest here: https://github.com/loganlinn/tesseract/blob/4c921165483b919dd0779f29b49153c5bdc56c47/src/cljx/tesseract/core.cljx#L55-L61
I am using that cursor to get the current version of the component out of the mount-env because it stores the built root component. We need the ability to get the 'canonical' component because a component could change by the time set-state!
processes.
Side-note: get-in wouldn't work for traversing DOMNodes like that AFAIK, but it would be trivial to write such a function.
One route might be to make cursors a little more intelligent to be able to additionally support traversals like you suggest, or consider lookups via data-tesseract-id
with a generated id (based on vdom cursor).
Need a function like
(get-dom container)
that returnsDOMNode
within the mounted container that co-responds tocomponent
. It can inspect cursor metadata to lookup container and QSA, but we'll want a faster access pattern such as generated ids