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

Get non-existent series now crashes with TypeError: item.options is null #6147

Closed
weakunix opened this issue Dec 15, 2016 · 3 comments
Closed

Get non-existent series now crashes with TypeError: item.options is null #6147

weakunix opened this issue Dec 15, 2016 · 3 comments

Comments

@weakunix
Copy link

@weakunix weakunix commented Dec 15, 2016

Highcharts.StockChart.get("seriesid") has an obvious bug in 5.0.6, (line 14511 of highstock.src.js):

function itemById(item) {
    return item.id === id || item.options.id === id;
}

should read:

return item.id === id || (item.options != null && item.options.id === id);
@pawelfus
Copy link
Contributor

@pawelfus pawelfus commented Dec 15, 2016

Hi @weakunix

Any chance to reproduce the issue? For me it works fine: http://jsfiddle.net/43gctL1f/

Thanks!

@weakunix
Copy link
Author

@weakunix weakunix commented Dec 16, 2016

Ok, it's a tricky one and it only fails when a setData is called on an existing series without redraw AND the number of points have been changed: http://jsfiddle.net/43gctL1f/9/

Can you remove the "Cant reproduce" label now?

@weakunix
Copy link
Author

@weakunix weakunix commented Dec 16, 2016

Just to add, when I originally said "obviously", I meant purely from a code robustness standpoint, in the sense that while it's relatively easy to make sure itemById is called with item never being null (since it's basically a lambda expression used locally in get), it's less easy to enforce that item.options never being null. In general, the safest code would be:

return (item !=null && item.id === id) || (item != null && item.options != null && item.options.id === id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants