Open zzz6519003 opened 9 years ago
@zzz6519003 Uhh, maybe some of this is wrong, but I'm pretty sure it works as follows.
In short:
React
to window
React = window.React;
makes a package-wide variable which is later exporteddelete window.React;
removes the window
variable "leak"Most of this package defines React
in: vendor/react-with-addons-0.13.0.js
. This creates window.React
.
Normally in Meteor apps:
// This is local to the current file
var ABC = function() { };
// This is globally available in the APP
XYZ = function() { };
But in packages:
// This is local to the current file
var ABC = function() { };
// This is globally available in the PACKAGE
XYZ = function() { };
In order to make a package global variables available in apps that include the package, you take one of these XYZ
variables and export it in package.js
.
So now to answer your question:
When you say:
XYZ = function() { }; // (i.e. without var)
It assigns to this
, which normally happens to be window
in the browser. But in a package, it is assigned to something else (for package-wide variables). Assigning React
to window
would be "bad" because if you didn't export it in package.js
it would be visible by apps anyway.
so long story short, it just wanna make it clean, just a good habit? thx buddy! :beer:
wondering what this does :beers: