backport bugfix from jsxgraph repo