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

Unregistering root node causes error #8

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

Unregistering root node causes error #8

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

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.unregisterNode('root') // => ERROR: Cannot read property 'children' of undefined

Problem: Lrud assumes that there's always a parent node of the node we want to unregister. This is an incorrect assumption, preventing us from unregistering a root node.

Problematic line that throws an error: https://github.com/bbc/lrud/blob/master/src/index.ts#L222

@codan84 codan84 changed the title Unregistering root node errors Unregistering root node causes error Jun 4, 2019
@thomascgray
Copy link
Contributor

@codan84 thanks for finding & raising an issue! We didn't look into unregistering without a parent, as we've not needed a reason to unregister the root node.

However, this is a valid use case, so will get a PR up and link it in here when complete.

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