- From: Domenic Denicola via GitHub <sysbot+gh@w3.org>
- Date: Wed, 29 Jun 2016 19:14:04 +0000
- To: public-houdini-archive@w3.org
(Sorry for cluttering up your pull request, @bfgeek!)
> I think our general rule as stated is probably wrong.
Hmm. I don't really agree, because I think the idea of objects having
realms is a bit unnatural. As a developer I think if anything I'd
expect the object's realm to that detected via its `__proto__` chain
(i.e., which `Object.prototype` does it bottom out in). But that's not
what relevant realm is; relevant realm is immutable over time. In
contrast, it makes sense to me to think of "what is the realm in which
the code that's running was 'declared'", i.e. it makes sense for
functions to have realms.
In other words, putting on my naive developer hat, I'd conceptualize
`import` to be written as something like
```js
Worklet.prototype.import = function (url) {
const resolvedURL = new URL(url, location.href).href; // (1)
// ...
fetch(resolvedURL, ...).then(...); // (2)
}
```
Here at both (1) and (2) I am implicitly using "current". I'd have no
way to get "relevant" from JS code; it's fairly unnatural to think of
doing so.
> In this particular case, it seems to me that relative URL resolution
for a worklet would naturally be a property of the worklet itself,
not of the function you happened to call to trigger the load.
In contrast, to me it seems that the function that I happened to call
to trigger the load is the one doing URL resolution, so it should be a
property of the function, since that's what's actually executing the
load.
> Or put another way, if you import two things into the same worklet
but using import methods from different globals for whatever reason
(probably because your libraries are doing something bizarre), would
you expect different base URLs to be used or the same base URL?
When you make it concrete like this, I can't say I have any particular
expectations. Both seem equally weird to me. You'd be forcing me as a
developer to confront the question of "what does a relative URL
really mean in a multi-global context," and I don't have a good
intuitive answer. I can only fall back to more principled arguments
like the above.
---
That said, I'm OK changing our position here. If you find my above
arguments unpersuasive, then I'd like to get the resulting advice
written up into HTML's multi-globals section. I can't tell if you're
advocating for a more general "relevant by default, current when
nothing else makes sense" position, or specifically for saying that
URL resolution should use a relevant object.
(We should probably also include a note that in constructors, relevant
= current.)
--
GitHub Notification of comment by domenic
Please view or discuss this issue at
https://github.com/w3c/css-houdini-drafts/pull/251#issuecomment-229458719
using your GitHub account
Received on Wednesday, 29 June 2016 19:14:11 UTC