whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
8.03k stars 2.62k forks source link

Potentially rename a script's base URL to its URL #3213

Open domenic opened 6 years ago

domenic commented 6 years ago

@annevk thinks this would be clearer, and asked me to file an issue to remind him. I think base URL is a good name for what it's used for (resolving relative imports), but will approve a PR to change it since @annevk seems to care strongly.

annevk commented 6 years ago

The rationale is that a base URL is derived from a resource's URL (unless otherwise specified, e.g., with <base>). The resource's URL is the real primitive. That's also why we call it import.meta.url, not .baseURL.

domenic commented 6 years ago

As noted in https://chromium.googlesource.com/chromium/src.git/+/282b0eeda63f32bb2ca2dbaa5ed42a4ca87378da, just "URL" is not actually correct, since for inline scripts it can be affected by <base>. So, I'm inclined to close this.

annevk commented 6 years ago

It's still import.meta.url for inline scripts though, right? It seems for style sheets we call this concept "location", though currently it's null for inline style sheets which seems rather broken as how would they resolve their URLs then? Owner node?

domenic commented 6 years ago

Yep, we used the shorter name for the API. It does sound like stylesheets are a bit broken?

annevk commented 6 years ago

Yeah maybe, CSS doesn't really define how it does fetching so... Should we strive for some more consistency between style sheets and scripts? (I realize I'm getting somewhat off-topic here.)

domenic commented 6 years ago

I think that would be good. They have somewhat similar models, with a "style sheet" spec struct vs. a "script" spec struct.

annevk commented 6 years ago

I guess the main problem here is that CSS has a rather bad track record when it comes to modeling. (Houdini mostly made it worse, it wasn't fixed at a fundamental level as far as I can tell.)