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

TypeError function has no method 'handler' #183

Closed
bluepioupiou opened this issue Feb 10, 2014 · 4 comments
Closed

TypeError function has no method 'handler' #183

bluepioupiou opened this issue Feb 10, 2014 · 4 comments
Labels

Comments

@bluepioupiou
Copy link

Hi all.

I'm new on sigma. I successfully loaded it and generated my edges and nodes. My graph displays well and I even succeded to use the forceAtlas.

But whenever I 'mouseover' the graph, try to click or to drag I have this error :

TypeError: Object function () {
cw.log(msg);
return newfunc.apply(this, arguments);
} has no method 'handler'

I can't properly zoom or see labels by going over a node.
Did I forgot something simple ?

Thanks in advance

@bluepioupiou
Copy link
Author

Update : Apparently it's due to an interraction with cubicweb. CubicWeb change the mecanisms on arrays. It adds some other objects and it's that that make sigma fail. Sigma try to use one of these objects as a handler

@cdevienne
Copy link
Contributor

Hi,

The issue comes from the fact that sigma.js iterate the arrays with the 'in' operator.

If a third-party library inject functions in the Array prototype (which is our case), its name is iterated as well as the indexes of the array, leading to this function being mistaken for a handler by sigma.js.

The solution is to change the way sigma.js iterate over the arrays. More specifically, we should replace:

for (j in SOMEARRAY) {
// ...
}

with

for (j = 0; j !== SOMEARRAY.length; j += 1) {
// ...
}

Another approach would be to still use the 'in' operator but to have a more defensive loop content that checks if the 'j' variable is indeed and integer : I highly doubt it is the way to go though.

I am working on a patch that implement the solution I propose, hoping it will be accepted.

Cheers,

Christophe

cdevienne added a commit to cdevienne/sigma.js that referenced this issue Feb 11, 2014
'for in' also iterate over additionnal attributes set on the Array prototype, leading to unexpected
behaviors.
To make sigma.js more defensive against third-party libraries modifying the Array prototype, a more
classic way of iterating is required.

This patch solve issue jacomyal#183.
@jacomyal
Copy link
Owner

Thanks to @cdevienne's last pull request #185, this issue should now be fixed.

@bluepioupiou
Copy link
Author

Great, thanks a lot guys

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants