worker-dom
worker-dom copied to clipboard
[Feature request] Document.location and Window.location
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
+1 for document.location
and window.location
, see the similar issue #8.
As written by @choumx in https://github.com/ampproject/worker-dom/issues/8#issuecomment-514409113
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.
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?
@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
A readonly API to start works for me, so long as it is very clearly documented and has tests.
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.
@niutech could I work on your PR with you?
@NicholasKao1029 Sure! That's what I was hoping for. You can pull my branch https://github.com/niutech/worker-dom/tree/location
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.
This may need an origin policy when trying to assign a new value to the location.
any update?
No, I have abandoned my work due to the lack of time.