Ok, I might not be explaining myself very well, but I'll try...
On Mon, Jul 6, 2015 at 3:49 PM, Jordan Santell <
jsan...@mozilla.com> wrote:
> What's the benefit of having a window global in these modules? It sounds
> like yet-another-loader-caveat where X is accessible in environment Y but
> not Z. We'd then have some modules that handle a global window, and others
> that take a passed in arg (all graph modules just take a doc or element).
>
I don't care specifically about `window` itself. Having all normal browser
APIs is what's important. This *removes* a loader caveat, where you are
doing web stuff but suddenly you don't have access to a web API that you
are used to. I thought we wanted to move our tools more like being normal
webpages.
Think long-term. When ES6 gets modules, surely we're going to end up using
that. And all those modules are going to be normal browser modules, not
some weird isolated from the browser module.
If anything, this is super important for migration. The majority of our
tools are stuck in a everything-is-global context and we've got to
modularize them, and having normal browser scope will hugely help a slow
migration path.
> Also, this will just lead to doing things in the global window, whether
> its someone unfamiliar with a tool, a contributor, or a quick fix needed,
> where the global starts mutating, or worse, views calling methods on other
> views. eslint would help, but its not in all tools yet, we would get an
> error for using a global, or ignore it, either way it doesn't sound like it
> prevents that case. Not sharing globals just hard prevents things like that
> happening.
>
I don't get this. There is *not* a shared global. A `var` decl at the top
is not global, it's all module scope. You would have to explicitly set
`window.foo = 5` or `setTimeout.bar = 10` or mutate an explicit global to
have side effects. There is no global scope, it's still all local by
default.
We just need a normal browser context.
> The SDK does not expose a global window, but if you wanted to access
> 'window.performance' for example, you'd have to use a browser window, async
> communicate with a content script, or explicitly define the global in the
> loader.
>
Yeah, I was wrong about the SDK.