-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[Timeline] item.parent === null - "Cannot read property 'top' of null" #3753
Comments
To reproduce: // -- DOM in Node --
const { JSDOM } = require('jsdom');
const jsDomInstance = new JSDOM(
'<html><head><script></script></head><body></body></html>',
{
pretendToBeVisual: true
}
);
global['window'] = jsDomInstance.window;
global['document'] = global['window'].document;
global['Element'] = global['window'].Element;
global['requestAnimationFrame'] = global['window'].requestAnimationFrame;
// -- Script --
const { Timeline, DataSet } = require('vis');
const uuid = require('uuid').v4;
const div = document.createElement('div');
const timeline = new Timeline(div, []);
const events = makeEvents(3);
timeline.setItems(new DataSet(events));
setTimeout(() => {
timeline.setItems(new DataSet(makeEvents(4)));
}, 1);
timeline.focus([events[0].id], { animation: false });
function createEvent(dateInput) {
return {
start: (date => (date.setDate(dateInput), date))(new Date()),
id: uuid(),
content: 'content'
};
}
function makeEvents(count) {
return new Array(count)
.fill(0)
.map((val, index) => createEvent(index + 1));
} |
hey guys, come on, isn't is an almende vis library is frontend library for visualization of data but NOT FOR Node.js? Thank you! |
@tbaltrushaitis and yet (https://github.com/almende/vis/blob/master/test/TimelineItemSet.test.js#L6) their own unit tests uses Node. My issue originates out of Mocha unit tests. The issue is a valid issue, resolved in my PR. It came from items in a |
Browser's window is NOT the same as object produced by JSDOM. |
Its close enough @tbaltrushaitis |
@yotamberk do you think you can release this sometime soon as a patch - our company is eagerly waiting on it. If not that is cool, we can fork. |
@yotamberk bump |
Component: Timeline
Version: 4.21.0
The issue doesn't seem to happen often, maybe 1 in 4. But in the below code snippet, the line in red seems to throw due to
group
being null. Is there a race condition somewhere I should be aware about? Am I best off not initializing the timeline until I have events ready to go?Thinking, is the
setItems
method thread safe, as in, if I callsetItems
now, then 50ms later call it again with a completely different set of items, is that maybe why things break?Example:
Stack:
Source:
function getItemVerticalScroll(timeline, item) { var leftHeight = timeline.props.leftContainer.height; var contentHeight = timeline.props.left.height; var group = item.parent; - var offset = group.top; var shouldScroll = true; var orientation = timeline.timeAxis.options.orientation.axis;
The text was updated successfully, but these errors were encountered: