Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registering a root node if one already exists #9

Closed
codan84 opened this issue Jun 4, 2019 · 1 comment · Fixed by #12
Closed

Registering a root node if one already exists #9

codan84 opened this issue Jun 4, 2019 · 1 comment · Fixed by #12

Comments

@codan84
Copy link

codan84 commented Jun 4, 2019

To replicate:

const { Lrud } = require('lrud')

const navigation = new Lrud()

navigation.registerNode('root', { orientation: 'vertical' })
navigation.registerNode('root', { orientation: 'horizontal' })

console.log(navigation.tree)

Problem: trying to register a root node again (with the same id, orientation etc doesn't matter) does not change the existing root node to the new one. Instead, it adds another node at the root of the navigation tree, except the node is added with an undefined id.

Expected behaviour: either throw an error to say this node already exists (make it explicit that we can't do it), or unregister existing root node (see other issue I submitted!) and register new one in it's place.

@thomascgray
Copy link
Contributor

@codan84 thanks again for finding & raising! After a bit of an internal discussion, we also agree LRUD should throw an exception in this instance. Getting a fix out now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants