SolidJS Universal - How does the method of tree creation get chosen?
I'm currently using SolidJS universal in order to dynamically create multiple trees of nodes as the primary tree is being built so that there is no need for traversal for every
insertNode()
. These other trees skip nodes that are in the primary tree, but still need to connect to nodes that are higher/lower in the tree, if that makes sense.
The trouble that I ran into was that in some cases (i.e. shallow trees), the tree is being created in a breadth-first approach. In other cases (i.e. wide/deep trees), the tree is being created in a depth-first approach. This makes it much more complex to know if nodes are being added bottom-up or top-down, and was wondering if there's a way to configure this, or know if there's a way of figuring out which method will be chosen. Thanks!7 Replies
Just to give an HTML example for better understanding, this tree will be created in a depth-first method:
This next example will be created in a breadth-first method:
I took a look into dom-expressions/universal (https://github.com/ryansolid/dom-expressions/blob/main/packages/dom-expressions/src/universal.js) and the complexity deterred me a little bit 😛
34444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444444////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Sorry, my cat... 🙀🤣
I never thought that this would actually happen
which solid-universal repository are you using?
Hi sorry I am using what is packaged in solidjs version 1.8.7
and checking the git history of the universal.js file I sent above, it hasn't been changed in >2 years
I took a look at the dom-expressions package again and was trying to work out exactly what it was doing as it calls the component functions, and I'm wondering if it has anything to do with how the tree is split into different components. If I move these elements from 3 Component into 1, the behavior changes:
This tree forms the same way as the first html tree sample I shared (depth first).
1 component:
this component forms in a breadth-first approach:
https://playground.solidjs.com/anonymous/e852440d-e23f-41a3-83c6-71ae8766f4f3
check the output tab with
universal rendering
checked although it's essentially the same for other modesOooh this is interesting. Is this the output from solid babel?