Open moniuch opened 10 years ago
What is use case? Container may have many children. But any node has only one parent. Search in all parent, grandparent, ...? I don't think this function is very useful.
The use case is when an object is within many containers. The function is as much useful as its jQuery companion. I missed it just a minute ago. On May 20, 2014 11:15 AM, "Anton Lavrenov" notifications@github.com wrote:
What is use case? Container may have many children. But any node has only one parent. Search in all parent, grandparent, ...? I don't think this function is very useful.
— Reply to this email directly or view it on GitHubhttps://github.com/ericdrowell/KineticJS/issues/931#issuecomment-43603131 .
Imagine having a main container (Group) consisting of other nested containers. They all receive clicks, but the handler has to check for an attribute (say: isEnabled) that is defined on the main container level only. How would I step up the container tree and stop at a given level?
The preferred way would be something like
shape.getParents(function(node){
return node.getClassName() === 'Group' && typeof node.getAttr('isEnabled') === true
})`.
Agreed? Do you have a better solution?
Please implement
Node.getParents()
method with filter function as argument, much likeNode.getChildren()