You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are many tree implementations that are already doing their own parent pointers. For example, in DOM nodes, you can always get to the parent via node.parentNode. We should have a config option for this so we don't end up doing duplicate work and introducing unnecessary error conditions.
This could be a config option (which also becomes a Treecle instance property). For treecle to properly use this, it needs to know both how to read parents, and set parents.
Strawman: A parent property whose value is either a string (read/write property name) or a { get: function(node), set: function(node, otherNode) } for more elaborate schemas.
For example, for the DOM, this could look like this:
I'm not convinced this is a good design: what if we need to specify where exactly the node gets appended? Not to mention this affects other properties too.
Perhaps it should be possible to just say parent: "parentNode" and just error if we try to use any properties that require writing parents. Or even have an option to turn that off and fail silently (since the tree may automatically handle that).
People should be able to use treecle for read-only stuff like walk() or closest() or getting complex familial relationships without having to also use its parent mgmt system (or have to implement complex parent setting helpers they don't need just to provide a value to parent.set).
The text was updated successfully, but these errors were encountered:
There are many tree implementations that are already doing their own parent pointers. For example, in DOM nodes, you can always get to the parent via
node.parentNode
. We should have a config option for this so we don't end up doing duplicate work and introducing unnecessary error conditions.This could be a config option (which also becomes a
Treecle
instance property). For treecle to properly use this, it needs to know both how to read parents, and set parents.Strawman: A
parent
property whose value is either astring
(read/write property name) or a{ get: function(node), set: function(node, otherNode) }
for more elaborate schemas.For example, for the DOM, this could look like this:
I'm not convinced this is a good design: what if we need to specify where exactly the node gets appended? Not to mention this affects other properties too.
Perhaps it should be possible to just say
parent: "parentNode"
and just error if we try to use any properties that require writing parents. Or even have an option to turn that off and fail silently (since the tree may automatically handle that).People should be able to use treecle for read-only stuff like
walk()
orclosest()
or getting complex familial relationships without having to also use its parent mgmt system (or have to implement complex parent setting helpers they don't need just to provide a value toparent.set
).The text was updated successfully, but these errors were encountered: