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

Difference in behaviour when spreading location object #1682

Open
anmolitor opened this issue Jan 9, 2025 · 0 comments
Open

Difference in behaviour when spreading location object #1682

anmolitor opened this issue Jan 9, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@anmolitor
Copy link

Describe the bug

When executing { ...window.location } in the browser, you get back an object containing all the usual properties like
{ href: ..., origin: ..., pathname: ..., search: ..., hash: ... } etc.
In happy-dom, this does not work, since the spread operator only considers non-private fields and the Location class currently stores a private URL instead.

To Reproduce
Steps to reproduce the behavior:

  1. Execute { ...window.location } in the dev tools of this tab
  2. Execute a happy-dom test and log { ...window.location } out
  3. See a noticable difference

Expected behavior
The outcome is the same (object with all properties of window.location)

Device:

  • any

Additional context
I suggest fixing this bug by adding non-private (they may be typescript-private but not #) fields to the location class,
which mirror the fields in the private URL field. When URL is set, also set all related fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant