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

[Feature request] Document.location and Window.location #1068

Open
Tofandel opened this issue Jun 19, 2021 · 12 comments
Open

[Feature request] Document.location and Window.location #1068

Tofandel opened this issue Jun 19, 2021 · 12 comments

Comments

@Tofandel
Copy link

It would be nice to support the Document.location api to be able to use Vue-Router (or other js framework routers) in web workers

@niutech
Copy link
Contributor

niutech commented Jul 1, 2021

+1 for document.location and window.location, see the similar issue #8.

@samouri
Copy link
Member

samouri commented Jul 12, 2021

As written by @choumx in #8 (comment)

window.location.search is no longer undefined but it returns WorkerLocation.search which is not the expected value. We'll need to hydrate this from the main thread for read access. Writing is another matter.

In order to support these features we'll need to hydrate the values from the main thread as well as keep it in sync as the Location is updated over time. Writing to the property would require creating a new command/processor for worker-->main-thread communication.

This is a great FR, but unfortunately worker-dom isn't heavily staffed right now.
I can't dedicate the time to implementing this now, but would be more than happy to review a PR and guide an implementer in the right direction.

@samouri samouri changed the title [Feature request] Document.location [Feature request] Document.location and Window.location Jul 12, 2021
@NicholasKao1029
Copy link

For a PR to get through how much of the Location API would need to be built out?

For example a read only version of the API, supporting only some the values?

@samouri
Copy link
Member

samouri commented Jul 12, 2021

@NicholasKao1029: in general we implement features on a need basis, since each feature we add has a cost in terms of bundle size.

A partial readonly API works for me.

cc @kristoferbaxter

@kristoferbaxter
Copy link
Contributor

A readonly API to start works for me, so long as it is very clearly documented and has tests.

@niutech
Copy link
Contributor

niutech commented Jul 12, 2021

I made the first draft of document.location support (PR #1075), but I don't know how to properly transfer the Location object between the main thread and worker, so it is not complete. But could @samouri or @kristoferbaxter have a look at this and maybe pick up the work? Thanks.

@NicholasKao1029
Copy link

@niutech could I work on your PR with you?

@niutech
Copy link
Contributor

niutech commented Jul 13, 2021

@NicholasKao1029 Sure! That's what I was hoping for. You can pull my branch https://github.com/niutech/worker-dom/tree/location

@AaronMLB
Copy link

I see some work on this has begun, but I'd like to add my support to the original request. It would be very helpful in reconstructing the AMP CORS requirements for security on amp-script Fetch API calls.

@cometkim
Copy link
Contributor

This may need an origin policy when trying to assign a new value to the location.

@surya0796
Copy link

any update?

@niutech
Copy link
Contributor

niutech commented Jan 29, 2023

No, I have abandoned my work due to the lack of time.

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

No branches or pull requests

8 participants