-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
feat: Add --location=<href> and globalThis.location #7369
Conversation
7df835a
to
7e252b6
Compare
11db3e1
to
e72b531
Compare
4fff3ec
to
24900f9
Compare
802654f
to
bd6e9bf
Compare
Discussed this briefly before with @nayeemrmn in chat a while back but I'll repeat it here since this is still pending. API Semantics are fine I think, but we might have to allow for this to change the origin of contexts, so if we can better to see this behind --unstable so that we aren't immediately locked into the flags semantics. This came up recently again with an awkward hack for origins, I think we've barely pried the lid off this can of worms (origin related issues). |
We need the flag either way so it can run web scripts out of the box. A similar thing came up with service workers: https://discord.com/channels/684898665143206084/684898665151594506/741039703943413873. This is the main priority for As for whether or not we want to allow changing the location at runtime down the line... I'd want to hear the use cases. I suspect they aren't isomorphic with the web. |
Yep thats fine, i'd just like to see the flag be unstable at first as all other new flags have been so we're not permanently locked into semantics we're just starting to unravel.
Not at runtime, but an open question is if --location should be the default import origin when origin is The referrer of import does change depending on the base of a web page AFAIK but isnt adressed here, so unstable to allow breaking revisions. |
Sorry I haven't paid as much attention to this as I should. A couple questions:
|
Another thought, especially for workers, it would be really handy to have a shortcut to set it to the cwd. |
This is probably the biggest question yet. One main use cases for having a window location, is being able to determine the script origin. Getting an origin for a file URL is explicitly not specified: https://url.spec.whatwg.org/#origin. Currently we do the same as Chrome, which is give all file URLs the same origin: This also rules out the cwd shortcut.
Yeah, although |
Yes, since you can get such a
Like allowing relative paths? As explained in the last section of the documentation, I think this only makes bad usage easier. People already have a way of specifying relatively located worker URLs with |
Actually I think it is handy, and local storage should do whatever local storage does when the origin is a local file. |
The |
Lots of web standards are unintuitive... 😄 But that is something to debate on a local storage PR. 😉 |
I disagree - this is not something we can push to the future, as this problem is not local storage specific. The core problem here is determining the window origin from the window location. We have to be aware of the consequences of allowing file URLs as a window location when landing this PR. There is nothing we can do about it later in the local storage PR (or any other PR that uses window origin). |
But I am not sure what you are arguing or proposing. You can't magic up another origin out of thin air. While I agree that if you set location, that you share the same storage bucket for all code that shares the same origin might be surprising for some, it is logical and I don't see any other alternative. That is something to make clear in the documentation versus holding up what is consistent logic. The alternative is to disallow What we haven't addressed though would be how |
That isn't my point - that is indeed totally expected. The unexpected part is that all file URLs share an origin. Most people likely expect that Also My main issue is that |
Fair enough. My thought was the benefit to workers, but as @nayeemrmn points out, there are better ways. There is no harm in disallowing them for now, I agree. |
9bab164
to
0643664
Compare
Core team discussed Given that release is scheduled for Tuesday I think it's best solution to bump this PR to 1.6.0 (yes, I know it was already bumped from 1.4.0). There is no immediate need for this flag in upcoming release and the first feature that requires it is the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - sorry for the very long delay @nayeemrmn and thank you for seeing this through.
@lucacasonato reports this is needed for fetch WPT tests, hence the sudden movement on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One final comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks a bunch @nayeemrmn. Sorry this took so long!
Closes #4981.
https://github.com/nayeemrmn/deno/blob/location/docs/runtime/location_api.md