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

adaptModel.findAncestor triggers an error if no ancestor of that type exists #2240

Closed
moloko opened this issue Oct 2, 2018 · 1 comment · Fixed by #2244
Closed

adaptModel.findAncestor triggers an error if no ancestor of that type exists #2240

moloko opened this issue Oct 2, 2018 · 1 comment · Fixed by #2244
Assignees

Comments

@moloko
Copy link
Contributor

moloko commented Oct 2, 2018

Subject of the issue/enhancement/features

If you do a findAncestor search on a contentObject to see if it has a contentObject as its ancestor - and it doesn't - an error is thrown.

(Kineo's pageIncompletePrompt extension does this to check to see if learner is being routed to a child page of the current page)

Your environment

Any

Steps to reproduce

Execute the following in the console:

require('core/js/adapt').findById('co-05').findAncestor('contentObjects');

Expected behaviour

no error should occur, the function should simply return undefined to indicate that no results were found

Actual behaviour

The error 'TypeError: returnedAncestor is undefined' is thrown.

@moloko
Copy link
Contributor Author

moloko commented Oct 2, 2018

Adding in if (!returnedAncestor) return; here would solve the immediate issue, but looking at the code following that the behaviour looks a bit odd, not sure why this would just return the original item's grandparent regardless of what type it is? Code seems to be making assumptions about the structure of the course that aren't necessarily correct...

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.

1 participant