SpiderStrategies / kalpa-tree

A tree implementation backed by D3
http://spiderstrategies.github.io/kalpa-tree/
ISC License
4 stars 2 forks source link

tree.get() can return an array #446

Closed mattsgarlata closed 5 years ago

mattsgarlata commented 5 years ago

When I call tree.get() with no arguments, the returned value is an array with one node.

I already coded a workaround in Scoreboard so this isn't high priority, but it seems like this method should not be returning an array.

Here's the tree data:

[{"id":1,"label":"root briefing","organizationId":1,"type":"briefing"},
{"id":2,"label":"briefing folder","type":"folder"},
{"id":3,"label":"sub-folder","parentId":2,"type":"folder"}]
mattsgarlata commented 5 years ago

I forgot to mention: this is a forest tree. FWIW here's what it looks like in Scoreboard

Screen Shot 2019-03-12 at 12 06 21 PM

nathanbowser commented 5 years ago

I think this would be a breaking change. See https://github.com/SpiderStrategies/kalpa-tree/issues/57

get without args returns root, and since this is a forest tree it returns an array of all the root nodes.

mattsgarlata commented 5 years ago

Oh, so if it's a forest it returns an array of all the roots? That makes sense so I'll just close this out. I wasn't thinking clearly about this one.