Skip to content

Graph.setEdge() does not work in phantomjs when first argument is object #31

Description

@artarf

It seems that phantomjs has a bug in strict mode. Consider you have following code:

"use strict";
function f(x) {
  x = 1;
  return arguments[0]; // in phantomjs this returns 1, regardless of the given parameter
}
console.log(f({ attr: "foo" }));

Graph.setEdge() currently relies on strict mode working correctly. Suggested implementation would be something along these lines:

Graph.prototype.setEdge = function(v, w, value, name) {
  var valueSpecified = arguments.length > 2;

  if (_.isPlainObject(v)) {
    name = v.name;
    if (arguments.length === 2) {
      value = w;
      valueSpecified = true;
    }
    w = v.w;
    v = v.v;
  } else {
    if (!_.isUndefined(name)) {
      name = String(name);
    }
  }
  v = String(v);
  w = String(w);
  // ... rest is working correctly

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions