Skip to content

.navigate(href) is broken when called without a callback #81

@JoshSGman

Description

@JoshSGman

In the documentation, it states that you can navigate programmatically using the .navigate method on a reference to the router component instance. Unfortunately, the source code requires a second argument to be passed in the form a function yet it doesn't state this anywhere. If you don't pass any additional arguments, the setPath method breaks as it expects a "navigation" argument to be an object:

Environment.prototype.navigate = function navigate(path, navigation, cb) {
  if (typeof navigation === 'function' && cb === undefined) {
    cb = navigation;
    navigation = {};
  }
  return this.setPath(path, navigation, cb);
}

Environment.prototype.setPath = function(path, navigation, cb) {
  if (!navigation.isPopState) {
    if (navigation.replace) {
      this.replaceState(path, navigation);
    } else {
      this.pushState(path, navigation);
    }
  }
  this.path = path;
  this.notify(navigation, cb);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions