Skip to content
This repository has been archived by the owner on Dec 16, 2023. It is now read-only.

Location class needs a toJSON method for proper serialization #1186

Open
edclement opened this issue Jan 12, 2019 · 0 comments
Open

Location class needs a toJSON method for proper serialization #1186

edclement opened this issue Jan 12, 2019 · 0 comments

Comments

@edclement
Copy link

In a standard browser, you can call JSON.stringify(window.location); This fails in zombie with a circular json reference.

class Location {

  constructor(history, url) {
    this._history = history;
    this._url = url || (history.current ? history.current.url : 'about:blank');
  }
...
}

I believe this occurs because the history class is attached to the location object and the history class actually attaches the browser object as a member as well.

here is the code:

toJSON() {
    return {
      hostname: this.hostname,
      href: this.href,
      origin: this.origin,
      hash: this.hash,
      host: this.host,
      pathname: this.pathname,
      port: this.port,
      protocol: this.protocol,
      search: this.search
    }
  }
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant